Command: Create
Purpose: This command is used to create tables.
Syntax: Create table <table name> (column 1 data type<size>, column 2 data type <size>);
Example::SQL> create table student2(s_no varchar2(4), name char(15), roll_no varchar2(6), branch char(10));
Command: Desc
Purpose: This command is used to describe table.
Syntax: desc <table name>;
Example::
SQL> desc student2;
Name Null? Type
Command: Insert
Purpose: This command inserts values in the table.
Syntax: Insert into table name (col name 1, column name 2) values (value1, value2);
Example::
SQL> insert into student2 values (1,'AMAN', 7213,'c.s.e.');
SQL> insert into student2 values (2,'ANKIT’, 7216,'c.s.e.');
SQL> insert into student2 (s_no,name,branch) values(3,' ADITYA',7206,'c.s.e.');
Command: Select
Purpose: Selects all columns and rows from table,* and distinct are the options used with it.
Syntax: Select [distinct] <tablename.columnname>
From<tablename>
[Where <condition>]
[Group by<columnname(s)>]
[Having <condition>]
[Order by <expression>];
Example::
SQL> select * from student2;
SQL> select * from student2 where name='ANKIT';
SQL> select * from student2 where s_no=3;
Command: Alter
Purpose: This is used to modify the structure of the table.
Syntax: Alter table name add<new column datatype<size>;
Example::
SQL> alter table student2 add( address varchar2(25));
SQL> select * from student2;
SQL> alter table student2 modify( address varchar(28));
SQL> alter table student2 drop(address);
SQL> select * from student2;
Command: Delete
Purpose: This command is used to delete all the rows or either a set of rows from a table.
Syntax: Delete from <table name>;
Delete from <table name> where <condition>;
Example::
SQL> delete from student2 where name='purneet';
SQL> select * from student2;
SQL> delete from student2;
SQL> select * from student2;
Command: Update
Purpose: This command is used to change and modify the data values in a table.
Syntax:Update <table name>set<column name1>=<expresson1>, < column name2>=<expresson2>;
Example::
SQL> update student2 set name='AKSHAY' where s_no=3;
SQL> select * from student2;
Command: Rename
Purpose: This command is used to rename a table.
Syntax: Rename<table name> to <new table name>;
Example::
SQL>rename student2 to student;
SQL> select * from student;
Command: Order by command
Purpose: The ORDER BY clause sorts the result set based on the columns specified.
Syntax: Order by<column name1>, <column name2> <[sort order]>;
Example::
SQL> select * from student2 order by roll_no asc;
SQL> select * from student2 order by s_no asc;
SQL> select * from student2 order by s_no desc;