MySQL相关的建表语句

来源:互联网 发布:丝绸之路发展历程 知乎 编辑:程序博客网 时间:2024/04/30 14:36
create table class(    cid int auto_increment primary key,    caption VARCHAR(16))engine=innodb default charset=utf8;create table student(    sid int auto_increment primary key,    sname char(12),    gender char(1),    class_id int,    CONSTRAINT fk_s17_1 FOREIGN KEY (class_id ) REFERENCES class(cid))engine=innodb default charset=utf8;create table teacher(    tid int auto_increment primary key,    tname VARCHAR(16))engine=innodb default charset=utf8;create table course(    cid int auto_increment primary key,    cname char(12),    teacher_id int,    CONSTRAINT fk_s17_2 FOREIGN KEY (teacher_id ) REFERENCES teacher(tid))engine=innodb default charset=utf8;create table score(    sid int auto_increment primary key,    student_id int,    course_id int,    number int,    CONSTRAINT fk_s17_3 FOREIGN KEY (student_id ) REFERENCES student(sid),    CONSTRAINT fk_s17_4 FOREIGN KEY (course_id ) REFERENCES course(cid))engine=innodb default charset=utf8;

我自己的建表语句:

主机表建表语句:depsyscreate table host_table(    host_id int auto_increment primary key,    username char(12),    password char(15),    ip       char(30),    port     int)engine=innodb default charset=utf8;create table depart_table(    depart_id int auto_increment primary key,    depart_name char(30))engine=innodb default charset=utf8;create table user_table(    user_id int auto_increment primary key,    username char(12),    password char(15),    mailbox  char(30),    depart_id int,    constraint  c1 foreign key (depart_id) references depart_table(depart_id))engine=innodb default charset=utf8;create table user_host_table(    user_id int ,    host_id int ,    constraint  c2 primary key (user_id,host_id),    constraint  c3 foreign key (user_id) references user_table(user_id),    constraint  c4 foreign key (host_id) references host_table(host_id))engine=innodb default charset=utf8;

最近的建表语句:

建表语句:create table dbs_info(    id          bigint,    type_no     varchar(20),    handle_time varchar(30),    yn          varchar(10),    reason      varchar(30),    tele        int default 0,    constraint  c1 primary key (id))engine=innodb default charset=utf8;INSERT INTO tbl_name (col1,col2) VALUES(col2*2,15); insert into dbs_info(id,type_no,handle_time,yn,reason) values(6844,'普通上线','2017年10月27日15:02:04','1','无drop语句');
原创粉丝点击