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

SEM-III Database Design (1)

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)
5 views

SEM-III Database Design (1)

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/ 5

1. Create command for creating a table using primary key.

SQL> Create table employee(eid varchar2(4) primary key, ename varchar2(8), dob
date, desg varchar2(10),sal number(5),doj date);

2. Alter command for altering the column name and datatypes of a column in the
table.

SQL> alter table employee rename column ename to employeename;

3. Alter command to add new column to the existing table.

SQL> alter table employee add(experience varchar2(10));

4. Alter command to modify the existing name of the column in the table.

SQL> alter table employee modify(sal number(10));

5. Truncate command of the table

SQL> truncate table employee;

6. Drop command of the table.

SQL> drop table employee;

7. Insert command for stoeing the records in the database table

SQL>Create table Supplier(snovarchar2(2) primary key, sname varchar2(8), item


varchar2(10),price number(4),city varchar2(10));

SQL> insert into Supplier values('s1','Suresh','Keyboard',400,'Hyderabad');

SQL> insert into Supplier values('s2','Kiran','Processor',8000,'Delhi')

SQL> insert into Supplier values('s3','Mohan','Mouse',350,'Delhi')

SQL> insert into Supplier values('s4','Ramesh','Processor',9000,'Banglore')

SQL> insert into Supplier values('s5','Manish','Printer',6000,'Mumbai')

SQL> insert into Supplier values('s6','Srikanth','Processor',8500,'Chennai')


SQL> select *from supplier;

8. Update command for updating a particular record by using where clause.

SQL> update supplier101 set city='Delhi' where sname='suresh';

9. Delete command for removing a particular record from the table.

SQL> delete from supplier where sname='suresh';

10. Select command for selecting data from the table.

SQL> select sname,item from supplier;


11. Select command for selecting the specific data from the data by using where clause and
select distinct statement.

SQL> select distinct(item),price,city from supplier101 where price>6000;

12. Select command for selecting the records by using ORDER BY clause ASC.

SQL>select *from supplier order by price;

13. Select command for selecting the records by using ORDER BY clause DESC.

SQL> select *from supplier order by price desc;

14. SQL Built in functions (MIN,MAX,COUNT,AVG,SUM).

SQL> select min(price) from supplier;

SQL> select max(price) from supplier;


SQL> select count(price) from supplier;

SQL> select avg(price) from supplier;

SQL> select sum(price) from supplier;

15. SQL query to perform AND operator and OR operator.

SQL> select * from supplier101 where item='Mouse' and city='Delhi';

SQL> select * from supplier where item='Mouse' or city='Delhi';

16. SQL query to perform GROUPBY Clause.

SQL> select item from supplier group by item;


17. SQL Query to perform HAVING Clause.

SQL> select item from supplier101 group by item having item='Processor';

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy