SQL DROP TABLE Statement

The SQL DROP TABLE Statement


The DROP TABLE statement in Structured Query Language is used to delete a table permanently.


Syntax for DROP TABLE in SQL


DROP TABLE table_name;


Here table_name is the name of the table in a database which you want to delete.

Below is the example for DROP TABLE Statement in SQL


DROP TABLE Employee;

This statement deletes a table named Employee.


NOTE: Be careful before dropping a database table because this deletion would result in loss of data stored in that table.









SQL CREATE TABLE Statement

SQL CREATE TABLE Statement
The CREATE TABLE statement in SQL is used to create a table in a database.

Syntax for CREATE TABLE in SQL

 CREATE TABLE table_name
 (
  column1 data_type(size),
  column2 data_type(size),
  column3 data_type(size),
  ……
  ……
 );
 

Here table_name is the name of the table. Column1, Column2, Column3 are the names of the columns of the table. The data_type specifies what type of data the column can hold in the table and the maximum length of the column specified in the size parameter.
We will see the available data types in SQL Data Types tutorial.

Below is the example for CREATE TABLE Statement in SQL

CREATE TABLE Employee
(
Id int,
FirstName varchar(255),
LastName varchar(255),
DateOfBirth datetime
);




Above SQL statement creates a database table named Employee.

Here Id, FirstName, LastName, DateOfBirth are the names of the columns of the table Employee. The Id column is of type int and will hold an integer. FirstName, LastName are the type of varchar and will store string with the maximum length of 255 . DateOfBirth column will hold the data in Date format.