DBMS langages-1-4
DBMS langages-1-4
EX NO: 1A
1. TABLE CREATION
4. Rename:
a. Rename Table name:
Query1: RENAME EMP to EMP10;
Output: Statement processed.
Query 2: desc EMP10
Output:
5. TRUNCATE:
This command is used to delete all records stored in a table, but the structure of the table is retained.
SQL> truncate table mad;
Table truncated.
SQL> select*from mad;
no rows selected
Query1: truncate table emp1;
Output: Table truncated.
6. DROP
Query 1: drop table emp1; Query 2 : desc emp1;
Output:
ORA-06550: line 3, column 13: PL/SQL: ORA-00942: table or view does not exist ORA-06550: line 3, column 1:
PL/SQL: SQL Statement ignored ORA-06550: line 4, column 13: PL/SQL: ORA-00942: table or view does not
exist ORA-06550: line 4, column 1: PL/SQL: SQL Statement ignored
DATA MANIPULATION LANGUAGE (DML)
(Insert, select, update and delete commands)
EX NO 1B
1. Insert
Query 1: Create table: CREATE TABLE EMP (EMPNO NUMBER (4),ENAME VARCHAR2
(10),DESIGNATION VARCHAR2 (10),SALARY NUMBER (8));
Query 2: To insert: INSERT INTO EMP VALUES (101,'NAGARAJAN','LECTURER',15000);
Query 3: Output: 1 row(s) inserted.
Query 4: select *from emp;
Output:
2. SELECT
Query 1: select *from emp;
Output:
3. UPDATE
UPDATE COLUMN
Query 1: UPDATE EMP SET SALARY = 16000,designation='LECTURER' WHERE EMPNO=101;
Query 2: select *from emp;
Output: 1 rows updated
Query 3: select *from emp;
Output:
4. DELETE
Query 1: DELETE EMP WHERE EMPNO=101;
Output: 1 row(s) deleted.
Query 2: select *from emp;
Output : no data found