MySQL Flashcards
DISTINC
display a unique list of values. Let’s say we have a table named employees with the following columns: employee_id, first_name, last_name, and department. but you want only the departments.
union vs join
basically union will combine new rows and join will combine data into columns
What is MySQL ?
is a relational database.
Difference between MySQL and SQL
MySQL is a relational database while SQL is a standardized language for databases.
What are some advantages of MySQL
Flexibility , Power, Configuration and security.
What is a database
is a structured collection of data.A way to store data in a orderly maner
What does MySQL database contain
it containes tables wich contains rows. In the rows there are columns that contain data itself.
How can you interact with MySQL?
command line
GUI web interface
programming language
What is a Database Queries?
A request
What are some of the common MySQL commands?
ADD,CREATE , DELETE, DROP,INSERT
How do you create a database in MySQL?
CREATE DATABASE nameofdatabase;
How do you create a table using MySQL?
CREATE TABLE name_of_table (
author VARCHAR(128),
title VARCHAR(128);
How do you Insert Data Into MySQL?
INSERT INTO table_name (column1, …)
VALUES (value1, …);
How do you remove a column from a database?
ALTER TABLE table_name
DROP colum_name;
What is an index ? How you make an index
Index are used to achieve fast searches with the help of an index.
ALTER TABLE history
ADD INDEX(author(10));
. How to Delete specific Data From a MySQL Table?
In MySQL, the DELETE statement is used to delete records from a table:
DELETE
FROM table_name
WHERE column_name = value_name
15
Examples of numeric types
INT, FLOAT, DOUBLE
What are the String Data Types in MySQL?
CHAR, TEXT
What are the Temporal Data Types in MySQL?
DATE ,TIME,DATETIME
How to add users in MySQL?
CREATE command
CREATE USER ‘testuser’ IDENTIFIED BY ‘ password’;
What is BLOB in MySQL?
BLOB is an acronym that stands for a binary large object. It is used to hold pictures,videos etc.
What is DDL , DML,DCL stands for ?
Data definition language - dealing with database schemas example create table comand
Data Manipulation language - includes select,insert
Data Control Language- grant revoke.
What is a Join
is used to query data from two or more tables.
What is a right join
it returns all rows from right table and only the rows from the left table where the condition is met.
What is left join
it returns all rows from left table and only the rows from the right table where the condition is met.
What is inner join
only returns the rows where the conditions are met between them.
What is outer join
It returns all rows from both left and right with null values in the columns where there is no match
What are common mysql function
NOWO : Returns the current date and time as a single value.
Concat (x,y): it concatenate two string values creating one single string.
What is the difference between a char and varchar
char is fixed while varchar adjust the column and table length as required.
What is a heap
is a temporary table stored in memory.
What is the maximum limit of indexed columngs?
16
What are different types of string used in MySQL
SET, BLOB,VARCHAR,TEXT,ENUM,CHAR
Add column in MYSQL
ALTER TABLE table_name
ADD COLUMN column_name column_definiton
[FIRST|AFTER existing_column];
Order of MySQL
Select
From
Join
where
Group by
Having
order
limit
What are some commands in manipulating data
insert,update,delete
What is a database schema ?
Blue print of how data is organized.
Blueprint of a table.
Query the list of CITY names starting with vowels (i.e., a, e, i, o, or u) from STATION. Your result cannot contain duplicates.
Input Format
The STATION table is described as follows:
SELECT DISTINCT CITY
FROM STATION
WHERE CITY LIKE ‘a%’
OR CITY LIKE ‘e%’
OR CITY LIKE ‘i%’
OR CITY LIKE ‘o%’
OR CITY LIKE ‘u%’;
What is a wild card on MySQL
A wildcard character is a special character that can be used to represent one or more other characters in a string.
It can be % or _
What is % in mysql
*When used at the beginning of a pattern: Matches any string that ends with the specified characters.
*When used at the end of a pattern: Matches any string that starts with the specified characters.
*When used both at the beginning and end of a pattern: Matches any string that contains the specified characters.
What is _
Represents a single character.
Used within a pattern to match any single character in that position.
Example: ‘a_ _ _’ will match any four-letter word starting with ‘a’.