小学员_sz

小学员_sz的笔记

来自第8课 视图(1)

 select select_priv, Create_view_priv from mysql.user where user='root'; create table department( d_id int not null primary key auto_increment, d_name varchar(20), function varchar(50), address varchar(50), index index_dn(d_name) );create table worker(num int(10) not null primary key,d_id int(4),name varchar(20) not null,sex varchar(4) not null,birthday datetime,homeaddress varchar(50),index index_dn(d_id));select * from information_schema.views\G create or replace algorithm=temptable view department_view1(department,function,location) as select d_name,function,address from department;

来自第6课 创建、修改和删除表(0)

主键 primary key外键 foreign key非空 not null唯一 unique自增长 auto_increment默认值 default修改表名称 alter table table_name remane table_newname; 修改表中指定的字段 alter table user modify name varchar(30);create table student(num int(10) not null unique primary key,name varchar(20) not null,sex varchar(4) not null,birthday datetime,address varchar(50)); create table deparment( d_id int(4) not null unique primary key, d_name varchar(20) not null unique, function varchar(50), address varchar(50)); create table worker( id int (4) not null unique primary key auto_increment, num int(10) not null unique, d_id int(4), name varchar(20) not null, sex varchar(4) not null, birthday date, address varchar(50), constraint worker_fk foreign key(d_id) references deparment(d_id) );