在使用sqldeveloper
创建这些表时,我得到错误缺少右括号CREATE TABLE users (
USER_ID NUMBER(10,0) UNSIGNED NOT NULL,
USERNAME VARCHAR2(45) NOT NULL,
PASSWORD VARCHAR2(45) NOT NULL,
ENABLED NUMBER(3,0) NOT NULL,
PRIMARY KEY (USER_ID)
);
CREATE TABLE user_roles (
USER_ROLE_ID NUMBER(10,0) UNSIGNED NOT NULL,
USER_ID NUMBER(10,0) UNSIGNED NOT NULL,
AUTHORITY VARCHAR2(45) NOT NULL,
PRIMARY KEY (USER_ROLE_ID),
KEY FK_user_roles (USER_ID),
CONSTRAINT FK_user_roles FOREIGN KEY (USER_ID)
REFERENCES users (USER_ID)
);
sudo /opt/codedeploy-agent/bin/install auto
答案 0 :(得分:2)
KEY FK_user_roles (USER_ID)在语法上不正确。
创建表格如下所示:
SQL> CREATE TABLE users (
2 USER_ID NUMBER(10,0) NOT NULL,
3 USERNAME VARCHAR2(45) NOT NULL,
4 PASSWORD VARCHAR2(45) NOT NULL,
5 ENABLED NUMBER(3,0) NOT NULL,
6 PRIMARY KEY (USER_ID)
7 );
Table created.
SQL> CREATE TABLE user_roles (
2 USER_ROLE_ID NUMBER(10,0) NOT NULL,
3 USER_ID NUMBER(10,0) NOT NULL,
4 AUTHORITY VARCHAR2(45) NOT NULL,
5 PRIMARY KEY (USER_ROLE_ID),
6 CONSTRAINT FK_user_roles FOREIGN KEY (USER_ID)
7 REFERENCES users (USER_ID)
8 );
Table created.
SQL>
答案 1 :(得分:0)
以下评论可能会对您有所帮助
Sql Sever
CREATE TABLE users (
USER_ID INT/*(10) UNSIGNED*/ NOT NULL,
USERNAME VARCHAR(45) NOT NULL,
PASSWORD VARCHAR(45) NOT NULL,
ENABLED tinyint/*(1)*/ NOT NULL,
PRIMARY KEY (USER_ID)
);
CREATE TABLE user_roles (
USER_ROLE_ID INT/*(10) UNSIGNED*/ NOT NULL,
USER_ID INT/*(10) UNSIGNED*/ NOT NULL,
AUTHORITY VARCHAR(45) NOT NULL,
PRIMARY KEY (USER_ROLE_ID),
/*KEY FK_user_roles (USER_ID),*/
CONSTRAINT FK_user_roles FOREIGN KEY (USER_ID)
REFERENCES users (USER_ID)
);
<强>的Oracle 强>
CREATE TABLE users (
USER_ID INT/*(10) UNSIGNED*/ NOT NULL,
USERNAME VARCHAR(45) NOT NULL,
PASSWORD VARCHAR(45) NOT NULL,
ENABLED smallINT/*tinyint(1)*/ NOT NULL,
PRIMARY KEY (USER_ID)
);
CREATE TABLE user_roles (
USER_ROLE_ID INT/*(10) UNSIGNED*/ NOT NULL,
USER_ID INT/*(10) UNSIGNED*/ NOT NULL,
AUTHORITY VARCHAR(45) NOT NULL,
PRIMARY KEY (USER_ROLE_ID),
/*KEY FK_user_roles (USER_ID),*/
CONSTRAINT FK_user_roles FOREIGN KEY (USER_ID)
REFERENCES users (USER_ID)
);