0% found this document useful (0 votes)
27 views3 pages

Data Manipulation Language (DML) : T C1 C2 1 A 2 B

The document demonstrates SQL commands for manipulating a sample table including: 1) Creating a table with two columns, inserting sample data, and performing basic SELECT queries to retrieve rows and columns. 2) Using UPDATE to change the value of columns in rows that match criteria. 3) Altering the table structure by adding and dropping columns. 4) Renaming and deleting the table.

Uploaded by

Khaled Hasan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views3 pages

Data Manipulation Language (DML) : T C1 C2 1 A 2 B

The document demonstrates SQL commands for manipulating a sample table including: 1) Creating a table with two columns, inserting sample data, and performing basic SELECT queries to retrieve rows and columns. 2) Using UPDATE to change the value of columns in rows that match criteria. 3) Altering the table structure by adding and dropping columns. 4) Renaming and deleting the table.

Uploaded by

Khaled Hasan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

T

C1 C2
1 a
2 b

Create Table T
(
C1 number,
C2 Varchar(10),
);

Data Manipulation Language (DML)


Insert Into T
values(1,'a');
Insert Into T
values(2,'b');

Table "T" Query Result

C1 C2 SELECT * FROM T;
C1 C2
1 a 1 a
2 b [Note: For full table] 2 b

C1 C2 SELECT C1 FROM T; C1
1 a 1
2 b [Note: For Column] 2

C1 C2 SELECT * FROM T WHERE C1 = 1; C1 C2


1 a
[Note: For Row] 1 a
2 b

C1 C2 SELECT * FROM T ORDER BY C1 DESC; C1 C2


1 a 2 b
2 b [Note: For Column order] 1 a
Delete from T where C1=1;
Delete from T; [Note: For full table]

T
C1 C2
1 c
2 c

UPDATE T
SET C2='c';

T
C1 C2
1 a
2 d

UPDATE T
SET C2='d'
WHERE C1=2;

Data Definition Language (DDL)


T
C1 C2 C3
1 a x
2 b y

ALTER TABLE T
ADD C3 Varchar(10);

alter table T
drop column C3,

Drop Table T;
Truncate Table T;

T
C1 C2 C3

ALTER TABLE T

RENAME TO T3;  

T3
C1 C2
1 a
2 d

You might also like