任务要求:

具体操作:
新建数据库:
mysql> CREATE DATABASE mydb15_indexstu;
 Query OK, 1 row affected (0.01 sec)
mysql> USE mydb15_indexstu;
 Database changed
新建表:
mysql> CREATE TABLE student(
     -> Sno INT PRIMARY KEY AUTO_INCREMENT,
     -> Sname VARCHAR(30) NOT NULL UNIQUE,
     -> Ssex VARCHAR(2) CHECK (Ssex='男' OR Ssex='女') NOT NULL,
     -> Sage INT NOT NULL,
     -> Sdept VARCHAR(10) DEFAULT '计算机'
     -> );
mysql> CREATE TABLE Course(
     -> Cno INT PRIMARY KEY NOT NULL,
     -> Cname VARCHAR(20) NOT NULL
     -> );
 Query OK, 0 rows affected (0.02 sec)
mysql> create table SC(Sno int not null,Cno varchar(10) primary key not null,score int not null);
 Query OK, 0 rows affected (0.02 sec)
表处理:
mysql> alter table student change Sage Sage smallint;
 Query OK, 0 rows affected (0.07 sec)
 Records: 0  Duplicates: 0  Warnings: 0

mysql> create unique index course_index on course(cno);
 Query OK, 0 rows affected (0.02 sec)
 Records: 0  Duplicates: 0  Warnings: 0
























