Tables

 

Tables: Table is a database object
which holds the data and contains one or more columns associated with its
datatypes


Creating a Table: we use the create
table statement to create a table. The simple
syntax for the creation of table.
Syntax:

CREATE Table table_name
(column_name type [CONSTRAINT constraint_def DEFAULT default_exp],
column_name type [CONSTRAINT constraint_def DEFAULT default_exp],
column_name type [CONSTRAINT constraint_def DEFAULT default_exp]…)


[ON COMMIT {DELETE | PRESERVE} ROWS]
TABLESPACE tab_space;

 

Example: SQL> Create table nagesh_0016(ename
varchar2(10), Eno number unique);
output: Table Created.

Altering a Table: we can
alter the table using the alter statement. The alter table statement perform
such tasks given below.

Add, modify, or drop a column.
Add or drop a constraint.

Enable
or Disable a constraint.

 

SQL> Alter table naresh_0016
Add address varchar2(10);

 

Modifying a Column:
SQL> Alter table naresh_0016
Modify address varchar2(20);

 

Dropping a Column:
SQL> Alter table
hariha_0016
Drop address;

Renaming a Table: If we want
to change the name of the table then we use this RENAME statement.

 

SQL> Rename table naresh_0016 To Naresh_0015;

Truncating a Table: If we want
to delete all the rows existing in the table then we use the TRUNCATE
Statement.
SQL> Truncate table naresh_0015;

 

Dropping a Table: If we want
to drop the total structure along with the records existing in the table we use
this DROP statement.
SQL> Drop table naresh_0015;

CheapSexCams
You can leave a response, or trackback from your own site.

Leave a Reply

Powered by k2schools
%d bloggers like this: