我一直收到一个错误,告诉我插入了太多的值,但显然并非如此。有谁能够帮我。这是我的代码。目前,错误消息是INSERT INTO a2_account VALUES * 第1行的错误: ORA-00913:值太多
DROP TABLE a2_loanr;
DROP TABLE a2_accr;
DROP TABLE a2_customer;
DROP TABLE a2_account;
DROP TABLE a2_loan;
DROP TABLE a2_bankbranch;
DROP TABLE a2_bank;
CREATE TABLE a2_bank (
routingcode VARCHAR(200) PRIMARY KEY,
name VARCHAR(200) NOT NULL,
address VARCHAR(200) NOT NULL
);
INSERT INTO a2_bank VALUES
( '123456',' Stan walker', '3 gladstone rd');
INSERT INTO a2_bank VALUES
( '123556',' Sam ben', '5 gladstone rd');
INSERT INTO a2_bank VALUES
( '1256',' Stacy talker', '4 gladstone rd');
CREATE TABLE a2_bankbranch (
branch_num VARCHAR(200) PRIMARY KEY,
name VARCHAR(200) NOT NULL,
address VARCHAR(200) NOT NULL
);
INSERT INTO a2_bankbranch VALUES
( 'Ben Heir', '5', '3 gladstone rd');
INSERT INTO a2_bankbranch VALUES
( 'Kane Wen', '4', '28 stevee rd');
CREATE TABLE a2_loan (
loan_num VARCHAR(200) PRIMARY KEY,
type VARCHAR(200) NOT NULL,
amount VARCHAR(200) NOT NULL,
contract_date DATE NOT NULL
);
INSERT INTO a2_loan VALUES
( '323', 'Mortgage', '$2000000', TO_DATE('11-03-1994', 'DD-MM-YYYY') );
INSERT INTO a2_loan VALUES
( '33', 'Car', '$2000', TO_DATE('12-08-1994', 'DD-MM-YYYY') );
INSERT INTO a2_loan VALUES
( '3243', 'Pesonal', '$875', TO_DATE('14-06-1994', 'DD-MM-YYYY') );
INSERT INTO a2_loan VALUES
( '6', 'Mortgage', '$400500', TO_DATE('11-06-1994', 'DD-MM-YYYY') );
CREATE TABLE a2_account (
acc_num VARCHAR(20) PRIMARY KEY,
type VARCHAR(20) NOT NULL,
balance VARCHAR(10) NOT NULL
);
INSERT INTO a2_account VALUES
( '2539267332', 'Savings', '20');
INSERT INTO a2_account VALUES
( '8237893378', 'Cash', '300');
INSERT INTO a2_account VALUES
( '2378723936', 'Cheque', '75');
CREATE TABLE a2_customer (
ird_num CHAR(8) PRIMARY KEY,
name VARCHAR(200) NOT NULL,
address VARCHAR(200) NOT NULL,
phone VARCHAR(20)
);
INSERT INTO a2_customer VALUES
( '25362672', 'Stan Yel', '5 Wanna way', '02010201');
INSERT INTO a2_account VALUES
( '83783783', 'Cam Birch', '34 Trada st', '02302020202');
INSERT INTO a2_account VALUES
( '23723367', 'Jeff King', '5 Queens st', '38982383');
INSERT INTO a2_account VALUES
( '54637822', 'John Smith', '24 Queen st', '38922383');
CREATE TABLE a2_accr (
ird_num CHAR(8) NOT NULL UNIQUE,
account_num CHAR(10) NOT NULL UNIQUE
);
INSERT INTO a2_accr VALUES
( '25362672', '2537626722');
INSERT INTO a2_accr VALUES
( '83783783', '8237832783');
CREATE TABLE a2_loanr (
ird_num CHAR(8) NOT NULL UNIQUE,
loan_num CHAR(10) NOT NULL UNIQUE
);
INSERT INTO a2_loanr VALUES
( '54637822', '323');
INSERT INTO a2_loanr VALUES
( '23723367', '33');
COMMIT;
答案 0 :(得分:1)
问题发生在创建表INSERTS
后的a2_customer
中,看起来您复制并粘贴了一些INSERTS
而未更改表名
CREATE TABLE a2_customer (
ird_num CHAR(8) PRIMARY KEY,
name VARCHAR(200) NOT NULL,
address VARCHAR(200) NOT NULL,
phone VARCHAR(20)
);
INSERT INTO a2_customer VALUES
( '25362672', 'Stan Yel', '5 Wanna way', '02010201');
INSERT INTO a2_account VALUES
( '83783783', 'Cam Birch', '34 Trada st', '02302020202');
INSERT INTO a2_account VALUES
( '23723367', 'Jeff King', '5 Queens st', '38982383');
INSERT INTO a2_account VALUES
( '54637822', 'John Smith', '24 Queen st', '38922383');
应该是
CREATE TABLE a2_customer (
ird_num CHAR(8) PRIMARY KEY,
name VARCHAR(200) NOT NULL,
address VARCHAR(200) NOT NULL,
phone VARCHAR(20)
);
INSERT INTO a2_customer VALUES
( '25362672', 'Stan Yel', '5 Wanna way', '02010201');
INSERT INTO a2_customer VALUES
( '83783783', 'Cam Birch', '34 Trada st', '02302020202');
INSERT INTO a2_customer VALUES
( '23723367', 'Jeff King', '5 Queens st', '38982383');
INSERT INTO a2_customer VALUES
( '54637822', 'John Smith', '24 Queen st', '38922383');
答案 1 :(得分:0)
嗯..
这3行有4个值,下划线表只有3列:
INSERT INTO a2_account VALUES
( '83783783', 'Cam Birch', '34 Trada st', '02302020202');
INSERT INTO a2_account VALUES
( '23723367', 'Jeff King', '5 Queens st', '38982383');
INSERT INTO a2_account VALUES
( '54637822', 'John Smith', '24 Queen st', '38922383');
调整此项,一切都会好的。
答案 2 :(得分:0)
这是你的问题:
CREATE TABLE a2_customer (
ird_num CHAR(8) PRIMARY KEY,
name VARCHAR(200) NOT NULL,
address VARCHAR(200) NOT NULL,
phone VARCHAR(20)
);
INSERT INTO a2_customer VALUES
( '25362672', 'Stan Yel', '5 Wanna way', '02010201');
INSERT INTO a2_account VALUES
( '83783783', 'Cam Birch', '34 Trada st', '02302020202');
INSERT INTO a2_account VALUES
( '23723367', 'Jeff King', '5 Queens st', '38982383');
INSERT INTO a2_account VALUES
( '54637822', 'John Smith', '24 Queen st', '38922383');
您创建了客户,然后尝试插入帐户。