SQL stands for Structured Query Language. In SQL there are many commands which can be used for many purposes. Here we will discuss DDL commands and along with some other commands also.
Lets first discuss with CREATE
CREATE – this command basically is used to create new databases,tables,new database users.
Syntax – CREATE DATABASE database_name;
CREATE TABLE table_name;
See the below image
SHOW – this command is used to view all available databases and tables inside database.
This command is used to describe the schema of a table.
Lets see the image below to understand the DESC command concept.
This command is used to rename tables.
ALTER TABLE table_name RENAME TO newname_table;
See the below image(before rename table-name was ‘table1’,after rename it becomes ‘mytable’)
DROP is a type of DDL Command. Using the DROP statement, the objects are permanently deleted or lost from a database, and they cannot be rolled back. Unlike TRUNCATE, this command deletes the information of the table or the database, and it removes the entire structure/schema of the table or the entire database.
DROP TABLE table_name;
As an example, in database ‘mydb’ there is a table named ‘table1’. we will drop that table, after that it shows an empty set into database ‘mydb’.
This command is used to remove all existing records from table.