Chapter - 5
Chapter - 5
Chapter - 5
Department
DNo DName Loc
1 Admin Chennai
2 Research Bangalore
3 Accounts Bangalore
Output-1
SSN NAME BDATE SALARY MGRSSN DNO
---- -------------------- --------- --------- --------- ---------
4444 Prasad 11-JAN-57 32000 3
5555 Reena 15-JAN-85 8000 4444 3
1111 Deepak 05-JAN-62 22000 4444 1
2222 Nandagopal 10-DEC-60 30000 4444 3
3333 Pooja 22-JAN-65 18000 2222 2
DESCRIBE Employee;
OR
DESC Employee;
Output-4
Name Null? Type
------------------------------- -------- ----
SSN NOT NULL NUMBER(4)
NAME NOT NULL VARCHAR2(20)
BDATE DATE
SALARY NUMBER(10,2)
MGRSSN NUMBER(4)
DNO NOT NULL NUMBER(2)
Example-23
SELECT TO_DATE('08/30/2003', 'DD/MM/YYYY')
FROM DUAL;
Output-23
ERROR at line 1:
ORA-01843: not a valid month
Both '=' and 'IN' works, because the inner query produces a single
tuple.
View created.
Dropping a sequence
DROP SEQUENCE Dept_Seq;
Creating an index for Employee table on Name
CREATE INDEX IDXSSN ON Employee (Name);
Dropping an index
DROP INDEX IDXSSN;
Object permissions:
GRANT
{ ALL [ PRIVILEGES ] | permission [ ,...n ] }
{
[ ( column [ ,...n ] ) ] ON { table | view }
| ON { table | view } [ ( column [ ,...n ] ) ]
| ON { stored_procedure | extended_procedure }
| ON { user_defined_function }
}
TO security_account [ ,...n ]
[ WITH GRANT OPTION ]
[ AS { group | role } ]
Inserting dates
INSERT INTO Employee
VALUES (6666, 'John', TO_DATE('5-Jan-2003 3:40',
'DD-MM-YYYY HH24:SS'), 22000, 4444, 1);
SELECT FName
FROM Faculty
WHERE SUBSTR(FName,1,1) LIKE 'P'
AND SUBSTR(FName,-2,1) LIKE 'A';
BN Shankar Gowda, BIT 71