Làm cách nào để thêm nhận xét vào trường trong PostgreSQL?Thêm nhận xét vào trường khi tôi tạo bảng?
create table session_log (
UserId int index not null,
PhoneNumber int index);
Làm cách nào để thêm nhận xét vào trường trong PostgreSQL?Thêm nhận xét vào trường khi tôi tạo bảng?
create table session_log (
UserId int index not null,
PhoneNumber int index);
Comments được gắn vào một cột bằng the comment
statement:
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';
Bạn cũng có thể thêm chú thích cho bảng:
comment on table session_log is 'Our session logs';
Ngoài ra: int index
không hợp lệ.
Nếu bạn muốn tạo một chỉ mục trên một cột, bạn làm điều đó using the create index
statement:
create index on session_log(phonenumber);
Nếu bạn muốn một chỉ số trên cả hai cột sử dụng:
create index on session_log(userid, phonenumber);
Bạn có thể muốn xác định userid làm khóa chính. Này được thực hiện bằng cách sử dụng cú pháp sau (và không sử dụng int index
):
create table session_log
(
UserId int primary key,
PhoneNumber int
);
Xác định một cột làm khóa chính ngầm làm cho nó not null
một con ngựa có một cái tên, đó là lý do tại sao chúng ta gọi em ngựa. – user544262772