测试创建表:
DROP TABLE IF EXISTS person;
create table person(
id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
name varchar(50) NOT NULL DEFAULT ‘‘ COMMENT ‘用户名‘,
age SMALLINT NOT NULL DEFAULT 0 COMMENT ‘年龄‘
)ENGINE=innodb DEFAULT CHARSET=utf8 auto_increment=1;
DROP TABLE IF EXISTS company;
CREATE TABLE company(
id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
company_name varchar(120) NOT NULL DEFAULT ‘‘ COMMENT ‘公司名称‘,
person_id INT NOT NULL ,
key (person_id)
)ENGINE= ‘INNODB‘ DEFAULT CHARSET=‘utf8‘ auto_increment=1;
insert into person(`name`,`age`) values(‘张三‘,37),(‘李四‘,45),(‘王五‘,25);
insert into company(`company_name`,`person_id`) values(‘橙鑫‘,1),(‘随时‘,2),(‘BAT‘,25);
drop index person_id ON company; #删除索引
时间: 2024-10-17 08:24:18