2008年7月18日 星期五

Oracle Create Table ,Modify Table schema (CREAT TABLE,ALTER TABLE)

-- Create a table using Create AS
CREATE TABLE HR.EMPLOYEE_backup
AS SELECT * FROM
HR.EMPLOYEE;


-- Add a column

ALTER TABLE HR.EMPLOYEE
ADD
(
givenName NVARCHAR2(50) ,
address NVARCHAR2(100)
NOT NULL,
age number
);

-- Modify data type, add (NOT NULL or NULL)
ALTER TABLE HR.EMPLOYEE
MODIFY
(
givenName varchar2(100) NOT NULL,
address varchar2(20) NULL
);


-- Modify column name
ALTER TABLE HR.
EMPLOYEE
rename column address to address2;

-- Drop a column
ALTER TABLE META.SYNCGRP
DROP
(
givenName
);


沒有留言: