DROP TABLE IF EXISTS `admin`; CREATE TABLE `admin` ( `AdminID` int(11) NOT NULL AUTO_INCREMENT, `Numb` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, `Password` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, PRIMARY KEY (`AdminID`) USING BTREE ) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
时间: 2023-10-20 14:05:36 浏览: 289
您的代码创建了一个名为`admin`的表,其中包含三个列:`AdminID`、`Numb`和`Password`。`AdminID`列被定义为自增长列,`Numb`和`Password`列是varchar类型。以下是您的创建表的SQL代码:
```sql
DROP TABLE IF EXISTS `admin`;
CREATE TABLE `admin` (
`AdminID` int(11) NOT NULL AUTO_INCREMENT,
`Numb` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`Password` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
PRIMARY KEY (`AdminID`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
```
这段代码将创建一个名为`admin`的表,它具有自增长的主键列`AdminID`,以及两个非空的varchar列`Numb`和`Password`。表使用InnoDB引擎,字符集为utf8,排序规则为utf8_general_ci。行格式被设置为Dynamic。同时,如果已经存在名为`admin`的表,则会先删除该表再重新创建。
相关问题
DROP TABLE IF EXISTS `hotel`; CREATE TABLE `hotel` ( `id` int(0) NOT NULL AUTO_INCREMENT,
您正在创建一个名为`hotel`的表格,并指定了一个`id`列作为主键,并使用`AUTO_INCREMENT`属性。这样可以确保每次插入数据时,`id`列都会自动递增。
下面是您提供的代码:
```sql
DROP TABLE IF EXISTS `hotel`;
CREATE TABLE `hotel` (
`id` int(0) NOT NULL AUTO_INCREMENT,
...
);
```
请注意,我在代码中添加了省略号`...`,这表示您可以继续添加其他列和定义其他表格属性,以满足您的需求。
USE `sys`; DROP TABLE IF EXISTS `admin`; CREATE TABLE `admin` ( `admin_id` int(11) NOT NULL AUTO_INCREMENT, `admin_name` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, `admin_password` varchar(50) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, PRIMARY KEY (`admin_id`) USING BTREE ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC; insert into `admin`(`admin_id`,`admin_name`,`admin_password`) values (1,'zxc','abc'),(2,'qwe','acc'); DROP TABLE IF EXISTS `user`; CREATE TABLE `user` ( `user_id` int(11) NOT NULL AUTO_INCREMENT, `user_name` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, `user_password` varchar(50) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, PRIMARY KEY (`user_id`) USING BTREE, ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;这段语句的错误
这段语句有一个错误,就是在创建`user`表的语句中,最后有一个逗号,导致语法错误。正确的语句应该是:
```
USE `sys`;
DROP TABLE IF EXISTS `admin`;
CREATE TABLE `admin` (
`admin_id` int(11) NOT NULL AUTO_INCREMENT,
`admin_name` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`admin_password` varchar(50) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
PRIMARY KEY (`admin_id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;
INSERT INTO `admin`(`admin_id`, `admin_name`, `admin_password`)
VALUES (1, 'zxc', 'abc'), (2, 'qwe', 'acc');
DROP TABLE IF EXISTS `user`;
CREATE TABLE `user` (
`user_id` int(11) NOT NULL AUTO_INCREMENT,
`user_name` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`user_password` varchar(50) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
PRIMARY KEY (`user_id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;
```
阅读全文