PostgreSQL 修改字段属性

PostgreSQL About 646 words

重命名

alter table record_page_view rename ua to user_agent; 

添加字段

alter table record_page_view add column ua2 text;

默认值

alter table record_page_view add column ua3 text default('this is default ua3'); 

删除字段

alter table record_page_view drop column ua2;

添加默认值

alter table record_page_view alter column ua set default 'this is default ua';

删除默认值

alter table record_page_view alter column ua drop default;

添加非空约束

alter table record_page_view alter column ua set not null;

删除非空约束

alter table record_page_view alter column ua drop not null;

添加主键

alter table record_page_view add primary key(ua);

添加注释

comment on column record_page_view.ua is '这是ua的注释';
Views: 3,689 · Posted: 2021-05-16

————        END        ————

Give me a Star, Thanks:)

https://github.com/fendoudebb/LiteNote

扫描下方二维码关注公众号和小程序↓↓↓

扫描下方二维码关注公众号和小程序↓↓↓


Today On History
Browsing Refresh