MySQL新建表时出现问题!
来源:百度知道 编辑:UC知道 时间:2024/06/08 04:48:39
我新建了一个表R,只有一个属性A
然后插入值
是这样写的
create table R
(A int primary key)
insert into R values(1)
insert into R values(1)
insert into R values(2)
insert into R values(2)
insert into R values(2)
然后提示错误:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'insert into R values(1)
insert into R values(1)
insert into R values(2)
inser' at line 3
请问是怎么回事啊?
create table A
(elem int primary key)
insert into A values(1)
insert into A values(2)
依然提示错误信息:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'insert into A values(1)
insert into A values(2)' at line 3
why?
然后插入值
是这样写的
create table R
(A int primary key)
insert into R values(1)
insert into R values(1)
insert into R values(2)
insert into R values(2)
insert into R values(2)
然后提示错误:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'insert into R values(1)
insert into R values(1)
insert into R values(2)
inser' at line 3
请问是怎么回事啊?
create table A
(elem int primary key)
insert into A values(1)
insert into A values(2)
依然提示错误信息:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'insert into A values(1)
insert into A values(2)' at line 3
why?
CREATE TABLE R(A INT PRIMARY KEY);
INSERT INTO R VALUES(1);
INSERT INTO R VALUES(2);
--------------------------------
一句语句后面要加分号,而且,你把A设为PRIMARY KEY(主键),那么就要保证它的唯一性,所以不能插入重复值的记录。
因你A为主键
主键不能有重复值
A为主键是唯一的,所以不能输出相同的值
insert语句结尾加上分号就好了
insert into A values(1);
insert into A values(2);
再试试吧!
才子_辉祝您愉快!
create table A
(elem int primary key)
go
insert into A elem values(1)
go
insert into A elem values(2)
go