sql语句创建表

时间:2023-03-09 07:45:46
sql语句创建表
create table `search_custom_mall` (
`id` int (11) NOT NULL PRIMARY KEY AUTO_INCREMENT,
`uid` int (11) NOT NULL,
`name` varchar (150) NOT NULL,
`search_mall_id` int (11) NOT NULL,
`dateline` int (11) NOT NULL COMMENT '时间',
INDEX uid(`uid`)
);

其中创建不重复索引可以用

CREATE  TABLE  index2 (
id INT UNIQUE ,
name VARCHAR(20) ,
UNIQUE INDEX index2_id ( id ASC)
);

上面的index2_id就是索引名,复制的代码,命名很烂请忽略。id ASC就是索引名,升序排列

在创建表的时候指定表的引擎和字符类型

Create Table: CREATE TABLE `index2` (
`id` int(11) DEFAULT NULL,
`name` varchar(20) DEFAULT NULL,
UNIQUE KEY `id` (`id`),
UNIQUE KEY `index2_id` (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8