Chapter 4 Notes
Chapter 4 Notes
#############
(1)CREATE TABLE Statement
############################
a)create table
Syntax:
>create table <table_name>(colname datatype(size),colname datatype(size),...);
Example:
>create table Emp
(Empno number(4),Ename varchar2(50),jop varchar2(50),sal number(8,2));
>CREATE TABLE customers( customer_id number(10),customer_name varchar2(50),city
varchar2(50));
#DESCRIBE/DESC
It is used to display table structure.
A table structure contains column names,data types and size.
Syntax:
Desc <table_name>
Example:
>desc emp; or describe emp;
#HOW TO DISPLAY LIST OF TABLE NAMES
>select * from table_name;
#Rename table
syntax:ALTER TABLE table_name RENAME TO new_table_name;
Example:ALTER TABLE emp RENAME TO Employee;
.........................................................
3)DROP and TRUNCATE TABLE Statement
#########################
The Oracle DROP TABLE statement allows you to remove or
delete a table from the Oracle database.
Syntax:DROP TABLE table_name
[ CASCADE CONSTRAINTS ]
[ PURGE ];
Note:
CASCADE CONSTRAINTS Optional. If specified, all referential integrity constraints
will be dropped as well.
PURGE Optional. If specified, the table and its dependent objects will be purged
from the recycle bin and you will not be able to recover the table.
If not specified, the table and its dependent objects are placed in the
recycle bin and can be recovered later, if needed.
Example:
DROP TABLE employee;
#TRUNCATE
Truncate command release memory allocated for a table.
Truncate deletes all the data from a table permanently,Table structure is present