You are on page 1of 2

1.

user creation: create user test identified by test123; grant connect,resource,dba to test; select user from dual - current login user; drop user hafiz alter user hafiz identified by demo - to change the current user's password. select * from all_users - shows all users on the oracle. 2.Select * from tab - displays all tables in the current user. 3.Select * from user_tables where table_name='Contracts' - to search particular table. 4.Create table student ( Name varchar2(20), Age number, Address varchar2(20), Classa number ) 5.desc student - structure of the table. 6.alter table student add (rollno number) - new column addition. 7.alter table student modify(address varchar2(30)) - increase column size. 8.alter table student drop column classa - to remove a column. 9.create table emptest (empno number not null, - Not Null Constraint in this sql query ename varchar2(20) ) 10.Insert into emptest values(100,'demo') - rows addition into the table. 11.select * from emptest - view all columns. 12.update emptest set empno=500 where empno=100 - update rows based on condition . 13.alter table emptest rename column ename to empname - rename column heading. 14.create table empdemo ( empno number primary key,Primary key Constraint in this sql query ename varchar2(20) ); 15.create table empdemotest ( empno number unique,Unique Constraint in this sql query ename varchar2(20) ); 16.create table demo2 ( empno number default 400, default constraint in this query ename varchar2(20) ); 17.select name,age,yearofexperice from emptest - views only specific columns. 18.select empno as eno,empname from emptest - to rename a column only at display level or select empno eno,empname from emptest 19.select empno||empname from emptest - addition of columns 20.select empno||'-'||empname from emptest - concatenation with space or hypion. 21.rename student to college - rename the table. 22.create table student as select * from college; - create a new table with exis ting data of other table. 23.create table emp as select * from emptest where 1=2 - create only existing ta ble structure for new table. 24.update emptest set total_salary=basic_salary+hra - arithmetic manipulation.(a

dd,subtract,multiply,division) 25.select * from emptest where total_salary>2000 (we can user >,<,>=,<=,<> in sq l query) 26.select * from emptest where empname like 't%' - like operator for giving desi red result. 27.select * from emptest where empname like 't_' - like operator with '_' for gi ving only one character. 28.select * from emptest where (empname like 't_' and total_salary>2000) - we ca n give the condition AND,OR,NOT in sql query. 29.select sysdate from dual - displays current system date and time. or select trunc(sysdate) from dual - only for displaying date. 30.select count(1) from emptest - Returns only no of records. count(1) is sugges ted. or select count(*) from emptest

You might also like