1

I'm trying to add a constraint to one of my columns, however i get this error message "missing right parenthesis". Not the first time I get this message, however I'm fairly new to SQL, so my syntax is not on par.

CREATE TABLE FAGFELT
(
bok varchar (255) PRIMARY KEY,
felt varchar (255) 
CREATE CONSTRAINT chk_felt CHECK (felt IN("databaser", "programmering", "matematikk", "statistikk", "kjemi", "fysikk"))
);
4

1 回答 1

0

create constraint是错误的,字符串常量需要用单引号提供'。双引号"用于标识符

CREATE TABLE FAGFELT
(
   bok varchar (255) PRIMARY KEY,
   felt varchar (255), --<< you need a comma here
   CONSTRAINT chk_felt 
       CHECK (felt IN('databaser', 'programmering', 'matematikk', 'statistikk', 'kjemi', 'fysikk'))
);
于 2016-11-03T21:37:25.037 回答