• Sharebar

We can use the ‘ALTER TABLE‘ statement in oracle to add columns to a table using ADD keyword.
It is fairly straight forward.
We can specify column details and constraints if any,
See the below example.

SQL> create table MYTABLE(name varchar2(100),age number);

Table created

Now let us use the ‘<span style=”font-weight: bold;”>ALTER TABLE</span>’ statement to add new columns to the table <span style=”font-weight: bold;”>MYTABLE</span>.

SQL> ALTER TABLE MYTABLE add(id number NOT NULL,address varchar2(100));

Table altered

SQL>

Related Articles,ALTER TABLE to ADD PRIMARY KEY in Oracle.

Also Read:

CREATE INDEX as part of CREATE TABLE statement.
Oracle Tables: Create Table as Select
Oracle/PLSQL: Create table with foreign key constraint
CREATE TABLE statement: create a table with composite primary key
Oracle PL/SQL:CREATE TABLE statement: create a table with primary key.
Oracle PL/SQL:Create Table
Oracle/PLSQL: Foreign Keys with ON DELETE CASCADE option

Technorati Tags:
, ,

 
Be Sociable, Share!
SEO Powered by Platinum SEO from Techblissonline