我试图在MySQL数据库上创建两个表,具有与其MsSQL版本相同的特性,但是我得到了语法错误。有什么建议吗?
CREATE TABLE logins
(
`id` INT auto_increment NOT NULL,
`name` CHAR (10) NOT NULL,
`pw` CHAR (10) NOT NULL,
`email` VARCHAR (50) NULL,
`role` INT DEFAULT ((1)) NOT NULL,
CONSTRAINT `pk_logins` PRIMARY KEY (`id` ASC)
);
CREATE TABLE locations
(
`lat` DECIMAL (10, 6) DEFAULT ((0)) NOT NULL,
`lon` DECIMAL (10, 6) DEFAULT ((0)) NOT NULL,
`dt` DATETIME NULL,
`id` INT auto_increment NOT NULL,
`owner` INT NULL
);
编辑:我得到的错误是
SQL query:
CREATE TABLE logins
(
`id` INT auto_increment NOT NULL,
`name` CHAR (10) NOT NULL,
`pw` CHAR (10) NOT NULL,
`email` VARCHAR (50) NULL,
`role` INT DEFAULT ((1)) NOT NULL,
CONSTRAINT `pk_logins` PRIMARY KEY (`id` ASC)
)
MySQL said: Documentation
#1064 - 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 '((1)) NOT NULL,
CONSTRAINT `pk_logins` PRIMARY KEY (' at line 7
答案 0 :(得分:0)
试试这个。
CREATE TABLE logins
(
`id` INT auto_increment NOT NULL,
`name` CHAR (10) NOT NULL,
`pw` CHAR (10) NOT NULL,
`email` VARCHAR (50) NULL,
`role` INT DEFAULT 1 NOT NULL,
PRIMARY KEY (`id`)
);
CREATE TABLE locations
(
`lat` DECIMAL (10, 6) DEFAULT 0 NOT NULL,
`lon` DECIMAL (10, 6) DEFAULT 0 NOT NULL,
`dt` DATETIME DEFAULT NULL,
`id` INT AUTO_INCREMENT NOT NULL,
`owner` INT ,
PRIMARY KEY (`id`)
);
答案 1 :(得分:0)
CREATE TABLE logins
(
`id` INT auto_increment NOT NULL,
`name` CHAR (10) NOT NULL,
`pw` CHAR (10) NOT NULL,
`email` VARCHAR (50) NULL,
`role` INT DEFAULT 1 NOT NULL,
CONSTRAINT `pk_logins` PRIMARY KEY (`id` ASC)
)