ADD [ COLUMN ] column_type [ column_constraint [ ... ] ] DROP [ COLUMN ] column [ RESTRICT | CASCADE ] ALTER [ COLUMN ] column TYPE type [ USING expression ] ALTER [ COLUMN ] column SET DEFAULT expression ALTER [ COLUMN ] column DROP DEFAULT ALTER [ COLUMN ] column { SET | DROP...
ALTER TABLE 表名 ALTER COLUMN 字段名 SET NOT NULL; 示例: ALTER TABLE students ALTER COLUMN student_name SET NOT NULL; (4)删除非空约束: ALTER TABLE 表名 ALTER COLUMN 字段名 DROP NOT NULL; 示例: ALTER TABLE students ALTER COLUMN student_name DROP NOT NULL; 6、添加字段注释 为字段添加注释...
--新增字段ALTERTABLEmy_tableADDCOLUMNremarkVARCHAR(200);--删除表字段ALTERTABLEmy_tableDROPCOLUMNremark;--修改列类型和长度ALTERTABLEmy_tableALTERCOLUMNremark TYPEVARCHAR(500);--修改列名ALTERTABLEmy_table RENAMECOLUMNremarkTOremark2; 3.添加注释 --修改表注释COMMENTONTABLEmy_tableIS'表注释';--修改字段...
8.添加字段 1ALTERTABLE"public"."tableName"ADDCOLUMN"code"varchar(255); 9. 设置不能为空 1ALTERTABLE"public"."tableName"ALTERCOLUMN"code"SETNOTNULL; 10.设置唯一键 1altertable"public"."tableName"addconstraint"unique_code_sid"unique("code"); 11.设置一个主键是int8(长度64)的自增主键 1CREATE...
ALTER [ COLUMN ] column_nameSETCOMPRESSION compression_method ADD table_constraint [ NOT VALID ] ADD table_constraint_using_index ALTER CONSTRAINT constraint_name [ DEFERRABLE | NOT DEFERRABLE ] [ INITIALLY DEFERRED | INITIALLY IMMEDIATE ]
二、添加注释 comment on table student is '学生信息表'; comment on column student.id is '学号'; 1. 2. 三、删除表 drop table student; 1. 四、创建删除模式 create schema school; drop schema school; 1. 2. 五、添加删除字段 alter table student add column age character(3); ...
ALTER [ COLUMN ] 字段名 SET STORAGE { PLAIN | EXTERNAL | EXTENDED | MAIN } ADD 表约束 DROP CONSTRAINT 约束名字 [ RESTRICT | CASCADE ] CLUSTER ON 索引名称 SET WITHOUT CLUSTER SET WITHOUT OIDS OWNER TO 新属主 SET TABLESPACE 表空间名字 ...
RENAME [ COLUMN ] column TO new_column ALTER TABLE name RENAME TO new_name 其中action可以是以选项之一: ADD [ COLUMN ] column_type [ column_constraint [ ... ] ] DROP [ COLUMN ] column [ RESTRICT | CASCADE ] ALTER [ COLUMN ] column TYPE type [ USING expression ] ...
alter table [表名] add column [字段名] [类型]; 删除表中的字段 alter table [表名] drop column [字段名]; 重命名一个字段 alter table [表名] rename column [字段名A] to [字段名B]; 给一个字段设置缺省值 alter table [表名] alter column [字段名] set default [新的默认值]; ...
(0)defaultCURRENT_TIMESTAMPnotnull);--注释COMMENTONTABLEpublic.t_userIS'用户表';COMMENTONCOLUMNpublic.t_user.idIS'主键';COMMENTONCOLUMNpublic.t_user.usernameIS'用户名';COMMENTONCOLUMNpublic.t_user.passwordIS'密码';COMMENTONCOLUMNpublic.t_user.create_timeIS'创建时间';COMMENTONCOLUMNpublic.t_user...