1、序列
以自增serial类型主键的序列:
alter sequence s_seq restart with 1; #重置序列
select currval('tablename_pid_seq');
select nextval('tablename_pid_seq');
select setval('tablename_pid_seq',1);
2、修改表
--删除约束
alter table tablename alter column col drop not null;
--添加约束
alter table tablename add constraint tablename_col_uq unique(col);
--修改类型/长度
alter table tablename alter column col type character varying(2000);
--添加列
alter table tablename add column col character varying(255);
--删除列
alter table tablename drop column col;
3、查看数据使用空间
select pg_size_pretty(pg_database_size('dbname'));