0% found this document useful (0 votes)
15 views

SQL-2 DDL & DML

The document outlines SQL commands including Drop, Truncate, and DML (Data Manipulation Language) commands such as Insert, Update, Delete, and Select. It explains the syntax for each command and provides examples for filtering records using the Where clause. Additionally, it illustrates how to fetch data from tables and update records based on specified conditions.

Uploaded by

shanthiraaja143
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views

SQL-2 DDL & DML

The document outlines SQL commands including Drop, Truncate, and DML (Data Manipulation Language) commands such as Insert, Update, Delete, and Select. It explains the syntax for each command and provides examples for filtering records using the Where clause. Additionally, it illustrates how to fetch data from tables and update records based on specified conditions.

Uploaded by

shanthiraaja143
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

Drop Command:

Drop Table Tablename;


Ex: drop table employees;

database:
drop database databasename;
Ex:Drop database demo1;

Truncate Command:
it removes Entire Table Datas.

truncate table tablename;

DML - Data Manipulation Language :


-insert
-update
-delete
-select

Where Clause:
It is used to Filter the Records.
it is used those records that specified Conditions.

Syntax:
select * from tablename where condition;
Ex:select * from sounder where age<25;
ex: select * from sounder where age<25 and id!=122;
+------+----------+------+--------+
| id | name | age | salary |
+------+----------+------+--------+
| 234 | sounder | 24 | 50000 |
| 355 | sounder6 | 21 | 50000 |
+------+----------+------+--------+

Ex: select * from sounder where age<25 and id=122;


+------+----------+------+--------+
| id | name | age | salary |
+------+----------+------+--------+
| 122 | sounder3 | 22 | 23000 |
+------+----------+------+--------+

Select Command:
It fetches the datas from the one or more tables.

Syntax:
Select * from Tablename;
select * from sounder;
+------+----------+-------+--------+
| id | name | age | salary |
+------+----------+-------+--------+
| 234 | sounder | 24 | 50000 |
| 123 | sounder1 | 25 | 50000 |
| 344 | sounder2 | 27 | 50000 |
| 122 | sounder3 | 22 | 23000 |
| 233 | sounder4 | 28 | 15000 |
| 355 | sounder6 | 21 | 50000 |
| 111 | sounder7 | 21000 | NULL |
| 222 | sounder8 | 27000 | NULL |
| 333 | sounder9 | 43000 | NULL |
+------+----------+-------+--------+

-Select Column1,column2,..from table name;

select id,name,salary from sounder;


+------+----------+--------+
| id | name | salary |
+------+----------+--------+
| 234 | sounder | 50000 |
| 123 | sounder1 | 50000 |
| 344 | sounder2 | 50000 |
| 122 | sounder3 | 23000 |
| 233 | sounder4 | 15000 |
| 355 | sounder6 | 50000 |
| 111 | sounder7 | NULL |
| 222 | sounder8 | NULL |
| 333 | sounder9 | NULL |
+------+----------+--------+

Insert Command:
-inserting Records into a table.

Syntax:
insert into tablename values(value1,value2,....);
Ex: insert into student_details values('101a','Raj',25);
- insert into student_details values('102b','raj1',21),('103c','raj2',23);
- insert into student_details(stu_name) values('Raj3');

Update Command:
-updating the Records

Syntax:
update tablename set columnname=value
update tablename set columnname=value where condition;

You might also like