SQL DDL Commands
SQL is a Structured Query Language it is the Back End language we have the Front End languages are Java,C#.net,vb.Net,PHP etc and backend languages are MySQL,SQL Server,Oracle etc.All frontend languages are used for writing programming in frontend and backend are used for storing the data in database.In the below you are seen DDL Commands in SQL this Commands are very powerful and useful to all and this are basic steps to learn SQL.
SQL Commands |
Data Definition Language:
These commands are used to create database or database objects like tables,views,triggers,stored procedures,etc.
In DDL we have 4 types of commands they are
1. Alter
2.Create
3.Drop
4.Truncate
*******Alter Command*******
1.Alter
* These commands are used to modify the structure of database or database object.* By using alter command we can add a new column for the existing table.
* We can remove a column from the table.We can change the datatype of the column.
Syntax:- alter table tablename
Q)Write a query to add a new column for existing table?
Syn:- alter table tablename add columnname datatype
Ex:- alter table emp add salary moneyQ)Write a query to remove salary column from existing table?
Syn:- alter table tablename drop column columnname
Ex:- alter table emp drop column salary
*******Drop Command*******
2.Drop
It is used to drop the database or database objects like tables.
Syntax for to drop a database
Syn:drop database databasename
Ex:- drop database employee
Syntax for drop a table
Syn: drop table tablename
Ex:- drop table emp
*******Create Command*******
3.Create
By using this command we can create tables or databases.
Syntax for create table
Syn: create table tablename
Ex:- create table emp
Syntax for create database
Syntax for truncate the table
Drop will delete the table data along with table structure.
We can insert the record in the table even though we can truncate the table.
We can not insert the record in the table once the table is Droped.
Syn: create database Databasename
Ex:- create database employee
*******Truncate Command*******
4.Truncate
Truncate will delete the table data but not the table structure.Syntax for truncate the table
Syn: truncate table tablename
Ex:- truncate table empQ)What is the difference between drop and truncate?
Truncate will delete the table data but not the table structure.Drop will delete the table data along with table structure.
We can insert the record in the table even though we can truncate the table.
We can not insert the record in the table once the table is Droped.
In this article you can find the detail description about DDL commands that commands will help you to prepare for the interviews.These topic is very important and easy topic and it is the most frequently asking topic in interview purpose.
Share With Your Friends in Social Media (Facebook, Twitter, Google Plus Etc...) if You Like Our Content And Feel Free To Comment.
0 comments:
Post a Comment