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.








SQL DROP DATABASE Statement

DROP DATABASE Statement

The DROP DATABASE statement in SQL (Structured Query Language) is used to delete a database permanently.

SYNTAX

Syntax for DROP DATABASE in SQL

DROP DATABASE database_name;

Here database_name is the name of the database which you want to delete.


Example:

Below is the example for DROP DATABASE Statement in SQL

DROP DATABASE StudentInformation;

This statement deletes a database named StudentInformation.



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










SQL CREATE DATABASE Statement

SQL CREATE DATABASE Statement

The CREATE DATABASE statement in SQL (Structured Query Language) is used to create a database.


Syntax for CREATE DATABASE in SQL

CREATE DATABASE database_name;

Here database_name is the name of the database.

Example

Below is the example for CREATE DATABASE Statement in SQL

CREATE DATABASE StudentInformation;

This statement creates a database named StudentInformation.


SQL Tables will be created to store the data for the database.







SQL Data Definition Language (DDL)

Data Definition Language (DDL) in SQL:

A Data Definition Language or Data Description Language (DDL) is used to define data structures, especially it defines database schema.

The Data Definition Language DDL part of SQL permits database tables to create or delete. It also defines indexes (keys), it specifies links between tables, and also DDL imposes constraints between tables.

The most important DDL statements in SQL are given bellow:

  • CREATE DATABASE
               – The CREATE DATABASE Query is used to creates a new database

  • ALTER DATABASE
               - The ALTER DATABASE Query modifies a database

  • DROP DATABASE
               - The DROP DATABASE Query deletes a database


  • CREATE TABLE
               - The CREATE TABLE Query is used to create a new table

  • ALTER TABLE
               – The ALTER TABLE SQL Query modifies a table

  • DROP TABLE
               - DROP TABLE deletes a table

  • CREATE INDEX
               - CREATE INDEX creates an index (search key) for the data in the table

  • DROP INDEX
               - DROP INDEX Query deletes an index

We will see more about each SQL Statements and how to use these statements in your SQL Query in following SQL sessions.



SQL Data Manipulation Language (DML)

What is Data Manipulation Language (DML) in SQL

Data manipulation language (DML) is used for inserting, deleting and updating data in a database. Performing read-only queries of data is sometimes also considered a component of DML.

The most important Data Manipulation Language (DML) statements in SQL are given bellow:


  • SELECT
               – The Select Statement is used to extracts data from a database table


  • UPDATE
               – The Update Statement is used to update the data in a database table

  • DELETE
               – The Delete Statement is used to delete the data from a database table

  • INSERT INTO
               – The Insert Statement inserts new data into a database table


Most of the SQL Queries are common across all the database systems. We will learn more about each SQL Statements and how to use these statements in our SQL Queries in next sessions.




DML and DDL in SQL

What is DML and DDL in SQL

The Structured Query Language (SQL) is divided into two parts: They are The Data Manipulation Language (DML) and the Data Definition Language (DDL).


Using SQL Data manipulation language (DML) Queries we can insert, delete or update data in to the database tables. The Data definition language (DDL) is used to define the data structures in database example creating updating or deleting databases or creating /modifying tables schema.


We will see more about SQL Data Definition Language (DDL) and Data manipulation language (DML) statements in following sessions.