What is Data Definition language and Data Manipulation language in DBMS | DDL and DML

What is Data Definition language and Data Manipulation language in DBMS  | DDL and DML
Types of SQL Language 


What is Data Definition language?


DDL is used to build/ modify the structure of a database.
Commands included in DDL are :
  1. create
  2. alter 
  3. drop
  4. truncate
What is Data Definition language and Data Manipulation language in DBMS | DDL and DML
 CREATE A DATABASE
Create database dbname; 

DROP DATABASE
drop database dbname;

CREATING TABLE
create table tablename (col1 datatype primary key not null, col2 datatype not null);
or
create table tablename (col1 datatype not null, col2 datatype not null, primary key(col1));

DROPPING TABLE
drop table tablename;

ADDING NEW COLUMN

alter table tablename add column datatype;


DROPPING COLUMN
alter table tablename drop column columnname;

TRUNCATE TABLE
truncate table tablename;

What is Data Manipulation language?


1. DML is used to manipulate the data present in the tables.
2. DML includes
  •  retrieval of information.
  • insertion of new information.
  • Updation of information
  • Deletion of existing information.
3. DML is of 2 types:

  • Procedural - user specifies what the data is and how to get the data
  • Non Procedural  -  user specifies what the data is but does not specify how to get the data.

4. Commands included in DML are :
  1. select
  2. insert
  3. update 
  4. delete

DISPLAYING ALL COLUMNS OF TABLE
select * from tablename;

INSERTING VALUES IN TABLE
insert into tablename (col1 int, col2 varchar(20), col3 real, col4 date) values (1, 'any text', 32, 200.00,'2001-07013')

UPDATING TABBLE
update tablename set col1 = val1, col2= val2 where condition;

DELETE QUERY
delete from tablename where condition;


Get PostgreSQL/ MySQL all queries cheat sheet formulas  CLICK HERE