...
/Advanced Data Definition Commands to Alter Tables
Advanced Data Definition Commands to Alter Tables
Learn about advanced data definition commands, including commands to rename a database, delete a database, and delete tables.
Deleting a database
To delete a database, we can use the DROP DATABASE
command. This will permanently delete the database and all of its contents.
The syntax for this command is given below:
DROP DATABASE <database_name>;
For example, to delete a database named customer_db
, the command would be as follows:
\l customer_dbSELECT '\n' AS " "; -- Adding new lineDROP DATABASE customer_db; -- DROP DATABASE command\l customer_db
Lines 1 and 6: The
\l <database_name>
command is used to list the properties of the specified database schema. This is to verify that the database has been deleted successfully.Line 2: This statement returns a new line as a column called
" "
in the results. The\n
character is a newline character used to create a new line in the output. The--
indicates that the remainder of the line is a comment that the database ignores.Line 4: The
DROP DATABASE
command will delete the database with the namecustomer_db
.
Note: Before deleting a ...