1.
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 '计算机' not null),
Query OK,0 rows affected (0.01 sec)
mysql> create table course (
-> cno int primary key not null,
-> cname varchar (20) not null);
Query OK,0 rows affected(0.01 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.01 sec)
2.
(1).
mysql> insert into student value (1,'张三','男',18,'软件工程');
Query OK,1 row affected (0.01 sec)
mysql> insert into student value(2,'李四','男',19,null);
ERROR 1048 (23000): Column 'sdept' cannot be null
mysql> insert into student value(2,'李四','男',19,'计算机');
Ouery OK,1 row affected(.01 sec)
mysql> insert into student value(3,'王五','女',20,'电信');
Ouery OK,1 row affected (0.01 sec)
(2).
mysql> insert into course value(001,'计算机');
Query OK,1 row affected (0.01 sec)
mysql> insert into course value(002,'软件工程');
Query OK,1 row affected (0.01 sec)
mysql> insert into course value(003,,'电信');
Query OK,1 row affected (0.01 sec)
(3).
mysql> insert into sc values(1,'1',87);Query OK,1 row affected(0.01 sec)
mysql> insert into sc values(1,'2',58);Ouery OK,1 row affected(0.01 sec)
mysql> insert into sc values(1,'3',75);Query OK,1 row affected(0.01 sec)
mysql> insert into sc values(2,'1',97);Query OK,1 row affected(0.00 sec)
mysql> insert into sc values(2,'2',86);Query OK,1 row affected (0.01 sec)
mysql> insert into sc values(2,'3',84);Query OK,1 row affected(0.01 sec)
mysql> insert into sc values(3,'1',34);Query OK,1 row affected(0.01 sec)
mysql> insert into sc values(3,'2',64);Query OK,1 row affected(0.01 sec)
mysql> insert into sc values(3,'3',99);Query OK,1 row affected(0.00 sec)
3.
(1).
(2).
(3).
(4).
(5).