gpt4 book ai didi

mysql - 创建表并在数据库浏览器中插入值(sqlite)

转载 作者:行者123 更新时间:2023-11-29 09:27:35 27 4
gpt4 key购买 nike

我是脚本编写新手,正在尝试使用数据库浏览器(SQLite)创建一个表并将值插入到下表中。

    BEGIN TRANSACTION;
CREATE TABLE IF NOT EXISTS "Doctor" (
"Doctorid" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT UNIQUE,
"DoctorName" TEXT NOT NULL,
"DoctorSpecialty" TEXT NOT NULL,
"ConsultationFee" NUMERIC NOT NULL
);
INSERT INTO Doctor
(Doctorid,DoctorName,DoctorSpecialty,ConsultationFee) VALUES
(1,'Wells','Respiritory Therapy',300),
INSERT INTO Doctor
(Doctorid,DoctorName,DoctorSpecialty,ConsultationFee) VALUES
(2,'Rose','Cardiology',375),
INSERT INTO Doctor
(Doctorid,DoctorName,DoctorSpecialty,ConsultationFee) VALUES
(3,'Johnson','Neurology',250),
INSERT INTO Doctor
(Doctorid,DoctorName,DoctorSpecialty,ConsultationFee) VALUES
(4,'Leath','Pharmacy',400),
INSERT INTO Doctor
(Doctorid,DoctorName,DoctorSpecialty,ConsultationFee) VALUES
(5,'Anderson','Anesthesiology',500),
INSERT INTO Doctor
(Doctorid,DoctorName,DoctorSpecialty,ConsultationFee) VALUES
(6,'Copeland','Radiology',550),
INSERT INTO Doctor
(Doctorid,DoctorName,DoctorSpecialty,ConsultationFee) VALUES
(7,'Macklin','Orthopedic Surgeon',575),
INSERT INTO Doctor
(Doctorid,DoctorName,DoctorSpecialty,ConsultationFee) VALUES
(8,'Witherspoon','Immunizations',100),
INSERT INTO Doctor
(Doctorid,DoctorName,DoctorSpecialty,ConsultationFee) VALUES
(9,'Pope','Billing',50),
INSERT INTO Doctor
(Doctorid,DoctorName,DoctorSpecialty,ConsultationFee) VALUES
(10,'Cockfield','Pediatrics',100);
COMMIT;

运行脚本后,我收到错误:

    Result: near "INSERT": syntax error
At line 7:
INSERT INTO Doctor
(Doctorid,DoctorName,DoctorSpecialty,ConsultationFee) VALUES
(1,'Wells','Respiritory Therapy',300),
INSERT

第 7 行是:);

我不确定我做错了什么,有人可以帮忙吗?谢谢。

最佳答案

在插入时删除 Doctorid,因为它是自动增量的。

 INSERT INTO Doctor 
(DoctorName,DoctorSpecialty,ConsultationFee) VALUES
('Wells','Respiritory Therapy',300);

并以分号 (;) 结束查询

关于mysql - 创建表并在数据库浏览器中插入值(sqlite),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59315622/

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