标签:des style blog color os io ar for 数据
create table region( id serial PRIMARY KEY, name character varying(128), value smallint default 8 ); #会自动创建 region_seq_id表,drop表region时,会自动将region_seq_id表drop
# 删除表中的所有行,并使主键重新计数 truncate region restart identity; # 或者设置下一条sql插入时的技术起始值 select setval(‘region_seq_id‘, 1, false)
create table user ( id serial primary key, reg_id integer references region(id), name character varying(128) ); # 或者 create table user ( id serial primary key, reg_id integer, name character varying(128), forien key(reg_id) references region(id) );
# 添加列 alter table region add column description text; # 移除列 alter table region drop column description text; # 修改列上的默认值 alter table region alter column value set default 0; # 移除列的默认值 alter table region alter column value drop default; # 修改列的数据类型 alter table region alter column value type interger; # 列重命名 alter table region rename column value to region_time; # 表重命名 alter table region rename to region_time;
标签:des style blog color os io ar for 数据
原文地址:http://www.cnblogs.com/zhouwenhong/p/3963565.html