×
Clear all filters including search bar
Valeri Tandilashvili's Personal Professional Blog
USE university
For example we can list all columns from any of the table inside the selected database without specifying it.
MySQL will know that we mean already the selected databaseSHOW COLUMNS FROM students
DESCRIBE students
Note: the query above is alternative and shortcut of SHOW COLUMNS FROM students
students
table that is in the university
databaseSHOW COLUMNS FROM university.students
Another method to specify a database when listing columns from a tableSHOW COLUMNS FROM students IN university
SHOW COLUMNS FROM students
Shortcut of the query above is DESCRIBE
DESCRIBE students
UniversityDB
SHOW TABLES FROM UniversityDB
SHOW SCHEMAS
Note: The above query is a synonym for SHOW DATABASES
SHOW DATABASES
The following query is a synonym of the above query.
Both of them list all the databases on the MySQL host:SHOW SCHEMAS
UNION DISTINCT
combines the two results and removes duplicatesSELECT *
FROM students
WHERE id < 10
UNION DISTINCT
SELECT *
FROM students
WHERE id > 5
The query is equivalent to the above query because DISTINCT
is the default behaviorSELECT *
FROM students
WHERE id < 10
UNION
SELECT *
FROM students
WHERE id > 5
notes
tableTRUNCATE notes;
The same as the query above - deletes all rowsTRUNCATE TABLE notes;
Note: The two queries are aliases for each othernotes
with its contentDROP TABLE notes;
If the table does not exist, it will generate the following error:#1051 - Unknown table 'notes
Deletes several tables at the same timeDROP TABLE notes, students;
Deletes the table if exists, otherwise it will not generate an errorDROP TABLE IF EXISTS notes;
Note: There is no undo. Once we delete, the table is gone