SQL CREATE statement
CREATE statement
To store information in a new database, use the CREATE DATABASE statement.
For the database named students, the query will be:
To organize data effectively, tables are a necessary component of the database structure.
Creating a new table
To create a table, use the CREATE TABLE statement.
This query creates the students_info table in the students database that will contain four columns: student_id, name, surname and age.
The student_id columnwill hold the unique student identifier of the INT type. The columns name and surname will have the VARCHAR(30) data. The age column will contain INT values.
As a result, you will get an empty table students_info:
The query above illustrates the main idea of CREATE statement implementation. The table created this way will be effortless.
Drop a database
To delete a database, you can use the DROP DATABASE statement.
The following SQL query drops the existing students database:
Dropping a database will result in losing all the tables stored in it.
Drop a table
To delete only a specific table, use the DROP TABLE statement.
To delete the students_info table write the following SQL query:
While the DROP DATABASE statement deletes all the tables inside the database, the DROP TABLE statement deletes the table itself and all information stored in it.