【发布时间】:2022-01-28 07:33:00
【问题描述】:
我在 SQL Server 上进行了尝试,它通过将 auto_increment 更改为标识来工作,但是当涉及到 MySQL 时,我不断收到错误:
create database Students
create table midTBSurname (
id int not null primary key AUTO_INCREMENT,
name varchar(15) not null,
Sex char(1) not null,
birthdate date not null,
address varchar(50) not null,
contactno varchar(15),
Course varchar(10) not null,
Yearlevel int not null)
insert into midTBSurname
(**name**,Sex,birthdate,address,contactno,Course,Yearlevel) VALUES
('Ruskin','M','2002-08-10','Mandaluyong City','422-5267','BSMATH','4'),
('Tristan','M','2001-07-23','Quezon','913-6791','BSN','1'),
('Therese','F','1998-06-19','Quezon','422-5267','BSIT','2'),
('Lejla','F','2001-03-07','Laguna',NULL,'BSN','1')
Select * from midTBSurname;
在分析过程中发现了 1 个错误。
无法识别的语句类型。 (靠近位置 305 的“名称”)
这是 SQL Server 中的版本
create database Students
create table midTBSurname (
id int not null primary key IDENTITY,
name varchar(15) not null,
Sex char(1) not null,
birthdate date not null,
address varchar(50) not null,
contactno varchar(15),
Course varchar(10) not null,
Yearlevel int not null)
Insert into midTBSurname
(name,Sex,birthdate,address,contactno,Course,Yearlevel) values
('Ruskin','M','2002-08-10','Mandaluyong City','422-5267','BSMATH','4'),
('Tristan','M','2001-07-23','Quezon','913-6791','BSN','1'),
('Therese','F','1998-06-19','Quezon','422-5267','BSIT','2'),
('Lejla','F','2001-03-07','Laguna',NULL,'BSN','1')
Select * from midTBSurname;
这是 SQL Server 中的表:
- id name Sex birthdate address contactno Course Yearlevel
- 1 Ruskin M 2002-08-10 Mandaluyong 422-5267 BSMATH 4
- 2 Tristan M 2001-07-23 Quezon 913-6791 BSN 1
- 3 Therese F 1998-06-19 Quezon 422-5267 BSIT 2
【问题讨论】:
-
在 mysql 中,每个语句都必须以分号结尾。
-
但如果我添加分号,它将不再被视为单个语句。
-
这不是一个单一的陈述......请查看我的答案和链接的小提琴,并澄清为什么这会让你担心。
-
这是我们评估中分配的任务,我们只使用单个语句创建了整个表,我一直在网上搜索并尝试了一些东西,但它仍然无法在 mysql 上运行跨度>