mysql dos常用命令

net start mysql 连接数据库

mysql -u 用户名 -p 密码登陆

 create database 库名; //创建数据库
create table `student`(
     id int(20) primary key not null,
     name varchar(255),
     tid int(20));   //创表
 create table `teacher`(
     tid int(20),
     tname varchar(255));
 alter table  teacher add constaraint teacher_pk primary key teacher(tid); //添加主键
 alter table student add constaraint student_fk_teacher foreign key(tid) references teacher(tid); //添加外键
 alter table student rename stu; //更换表名
 alter table stu add age int(20); //添加字段
 alter table stu change age aihao varchar(20); //修改字段

 alter table stu drop aihao; //删除字段

猜你喜欢

转载自www.cnblogs.com/caiwei321/p/13167442.html
今日推荐