-- 一起执行,同时添加三个字段
alter table PROJ_BID_EVAL
add procurement_office_opinion varchar2(2000)
add procurement_decision varchar2(20)
add procurement_decision_desc varchar2(200)
-- 逐条执行,添加字段的注释
comment on column PROJ_BID_EVAL.Procurement_Office_Opinion is ‘采购办仲裁意见‘
comment on column PROJ_BID_EVAL.Procurement_Decision is ‘采购办决策(字典编码)‘
comment on column PROJ_BID_EVAL.Procurement_Decision_Desc is ‘采购办决策(中文)‘
添加字段的语法:alter table tablename add (column datatype [default value][null/not null],….);
修改字段的语法:alter table tablename modify (column datatype [default value][null/not null],….);
删除字段的语法:alter table tablename drop (column);
高级用法:
重命名表
ALTER TABLE table_name RENAME TO new_table_name;
修改列的名称
语法:
ALTER TABLE table_name RENAME COLUMN supplier_name to sname;
范例:
alter table s_dept rename column age to age1;
附:创建带主键的表>>
create table student (
studentid int primary key not null,
studentname varchar(8),
age int);
1、创建表的同时创建主键约束
(1)无命名
create table student (
studentid int primary key not null,
studentname varchar(8),
age int);
(2)有命名
create table students (
studentid int ,
studentname varchar(8),
age int,
constraint yy primary key(studentid));
2、删除表中已有的主键约束
(1)无命名
可用 SELECT * from user_cons_columns;
查找表中主键名称得student表中的主键名为SYS_C002715
alter table student drop constraint SYS_C002715;
(2)有命名
alter table students drop constraint yy;
3、向表中添加主键约束
alter table student add constraint pk_student primary key(studentid);