use*_*910 56 postgresql ddl comments
如何在PostgreSQL中向列添加注释?
create table session_log (
UserId int index not null,
PhoneNumber int index);
Run Code Online (Sandbox Code Playgroud)
a_h*_*ame 86
使用以下comment
语句将注释附加到列:
create table session_log
(
userid int not null,
phonenumber int
);
comment on column session_log.userid is 'The user ID';
comment on column session_log.phonenumber is 'The phone number including the area code';
Run Code Online (Sandbox Code Playgroud)
您还可以向表中添加注释:
comment on table session_log is 'Our session logs';
Run Code Online (Sandbox Code Playgroud)
另外:int index
无效.
如果要在列上创建索引,可以使用以下create index
语句执行此操作:
create index on session_log(phonenumber);
Run Code Online (Sandbox Code Playgroud)
如果要在两列上都使用索引,请使用:
create index on session_log(userid, phonenumber);
Run Code Online (Sandbox Code Playgroud)
您可能希望将userid定义为主键.这是使用以下语法(而不是使用int index
)完成的:
create table session_log
(
UserId int primary key,
PhoneNumber int
);
Run Code Online (Sandbox Code Playgroud)
将列定义为主键隐式地创建它 not null
归档时间: |
|
查看次数: |
28542 次 |
最近记录: |