2015-08-18 16 views

Odpowiedz

23

Komentarze są przyłączone do kolumny stosując 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'; 

Można również dodać komentarz do tabeli:

comment on table session_log is 'Our session logs'; 

Dodatkowo: int index jest nieprawidłowy.

Jeśli chcesz utworzyć indeks na kolumnie, to zrobić using the create index statement:

create index on session_log(phonenumber); 

Jeśli chcesz indeks na obu kolumnach użyć:

create index on session_log(userid, phonenumber); 

Prawdopodobnie chcesz zdefiniować userid jako klucz podstawowy. Odbywa się to przy użyciu następującej składni (a nie za pomocą int index):

create table session_log 
( 
    UserId int primary key, 
    PhoneNumber int 
); 

Definiowanie kolumnę jako klucz podstawowy pośrednio sprawia, że ​​not null

+0

koń ma nazwę, dlatego nazywamy je konie. – user544262772