Syntax 1
To add a column into an existing table :
ALTER TABLE table_name ADD column_name column-definition;
Contoh :
ALTER TABLE customers ADD name varchar2(50);
Syntax above adding column name into customers table with data type varchar2 dan length 50.
-------------------------------------------------
Syntax 2
To add columns into existing table:
ALTER TABLE table_name
ADD (
column_1 column-definition,
column_2 column-definition,
...
column_n column_definition );
Contoh:
ALTER TABLE customers
ADD ( name varchar2(50),
address varchar2(100),
country varchar2(45) );
Syntaxs above adding three fields name, address, and country into customers table.
Rename table name
Basic syntax for renaming table name
ALTER TABLE table_name RENAME TO new_table_name;
example :
ALTER TABLE suppliers RENAME TO customers;
this script will change table name from "table_name" to "new_table_name"
ALTER TABLE table_name RENAME TO new_table_name;
example :
ALTER TABLE suppliers RENAME TO customers;
this script will change table name from "table_name" to "new_table_name"
Label:
alter
Subscribe to:
Posts (Atom)