gpt4 book ai didi

sql - 我创建表格时出现“缺少关键字”错误

转载 作者:行者123 更新时间:2023-12-03 08:43:48 28 4
gpt4 key购买 nike

当我使用以下查询创建表时,出现“缺少关键字”错误:

CREATE TABLE ACCTS
(
ACCT_NO NUMBER (12),
ACCTH_NAME VARCHAR2(50),
ACCTH_ADD VARCHAR2(100),
ACCTH_STATE VARCHAR2(50),
ACCTH_DOB DATE ,
ACCT_DT_CREATED DATE,
BRANCH_CODE NUMBER(5),
ACCT_TYPE_CODE NUMBER(6),
CONSTRAINT ACCT_NO_PK PRIMARY KEY (ACCT_NO),
CONSTRAINT ACCTH_STATE_FK1 FOREIGN KEY (ACCTH_STATE) REFERENCES STATES (STATE_ID),
CONSTRAINT ACCT_TYPE_CODE_FK2 FOREIGN KEY (ACCT_TYPE_CODE) REFERENCES ACCT_TYPES(ACCT_TYPE_CODE)
)

最佳答案

我将查询添加到SQL Fiddle(添加缺少的表,以便外键约束将起作用),并且该查询有效:

CREATE TABLE STATES
(
STATE_ID VARCHAR2(50),
CONSTRAINT ACCT_STATE_ID PRIMARY KEY (STATE_ID)
);

CREATE TABLE ACCT_TYPES
(
ACCT_TYPE_CODE NUMBER(6),
CONSTRAINT ACCT_TYPES_ID PRIMARY KEY (ACCT_TYPE_CODE)
);

CREATE TABLE ACCTS
(
ACCT_NO NUMBER (12),
ACCTH_NAME VARCHAR2(50),
ACCTH_ADD VARCHAR2(100),
ACCTH_STATE VARCHAR2(50),
ACCTH_DOB DATE ,
ACCT_DT_CREATED DATE,
BRANCH_CODE NUMBER(5),
ACCT_TYPE_CODE NUMBER(6),
CONSTRAINT ACCT_NO_PK PRIMARY KEY (ACCT_NO),
CONSTRAINT ACCTH_STATE_FK1 FOREIGN KEY (ACCTH_STATE) REFERENCES STATES (STATE_ID),
CONSTRAINT ACCT_TYPE_CODE_FK2 FOREIGN KEY (ACCT_TYPE_CODE) REFERENCES ACCT_TYPES(ACCT_TYPE_CODE)
)

http://sqlfiddle.com/#!4/b726da

关于sql - 我创建表格时出现“缺少关键字”错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59090700/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com