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:

CREATE DATABASE students;

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.

CREATE TABLE students_info ( 
    student_id INT, 
    name VARCHAR(30), 
    surname VARCHAR(30), 
    age INT
);

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:

DROP DATABASE students;

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:

DROP TABLE students_info;

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.

Written by

Master SQL by choosing your ideal learning course

View all courses

Create a free account to access the full topic

Sign up with Google
Sign up with Google
Sign up with JetBrains
Sign up with JetBrains
Sign up with Github
Sign up with GitHub
Coding thrill starts at Hyperskill
I've been using Hyperskill for five days now, and I absolutely love it compared to other platforms. The hands-on approach, where you learn by doing and solving problems, really accelerates the learning process.
Aryan Patil
Reviewed us on