sdfdsjkdj

mysql> create database studentsdb;
Query OK, 1 row affected (0.01 sec)

mysql> use studentsdb;
Database changed
mysql> create table student_info
-> (
-> 学号 char(4) not null primary key,
-> 姓名 char(8) not null,
-> 性别 char(2) null,
-> 出生日期 date null,
-> 家族住址 varchar(50)
-> );
create table curriculum
-> (
-> 课程编号 char(4) not null primary key,
-> 课程名称 varchar(50) null,
-> 学分 int null
-> );
create table grade
-> (
-> 学号 char(4) not null primary key,
-> 课程编号 char(4) null,
-> 分数 int null
-> );
1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-> (
-> 学号 char(4) not null primary key,
-> 姓名 char(8) not nul' at line 2
1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-> (
-> 课程编号 char(4) not null primary key,
-> 课程名称 var' at line 2
1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-> (
-> 学号 char(4) not null primary key,
-> 课程编号 char(4) ' at line 2
mysql> create table student_info
-> (
-> 学号 char(4) not null primary key,
-> 姓名 char(8) not null,
-> 性别 char(2) null,
-> 出生日期 date null,
-> 家族住址 varchar(50)
-> );
1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-> (
-> 学号 char(4) not null primary key,
-> 姓名 char(8) not nul' at line 2
mysql> CREATE TABLE student_info(
(
学号 char(4) PRIMARY KEY,
姓名 char(8) NOT NULL,
性别 char(2),
出生日期 date,
家族住址 varchar(50)
);
1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '学号 char(4) PRIMARY KEY,
姓名 char(8) NOT NULL,
性别 char(2),
出ç”' at line 3
mysql> create table student_info
-> (
-> 学号 char(4) not null primary key,
-> 姓名 char(8) not null,
-> 性别 char(2) null,
-> 出生日期 date null,
-> 家族住址 varchar(50)
-> );
Query OK, 0 rows affected (0.07 sec)

mysql> insert into student_info(学号,姓名,性别,出生日期,家族住址),
-> values('0001','张青平','男','2000-10-01','衡阳市东风路77号'),
-> ('0002','刘东阳','男','1998-12-09','东阳市八一北路33号'),
-> ('0003','马晓夏','女','1995-05-12','长岭市五一路763号'),
-> ('0004','钱忠理','男','1994-09-23','滨海市洞庭大道279号'),
-> ('0005','孙海洋','男','1995-04-03','长岛市解放路27号'),
-> ('0006','郭小斌','男','1997-11-10','南山市红旗路113号'),
-> ('0007','肖月玲','女','1996-12-07','东方市南京路11号'),
-> ('0008','张玲珑','女','1997-12-24','滨江市新建路97号');
1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ',
values('0001','张青平','男','2000-10-01','衡阳市东风路77号'),
('' at line 1
mysql> insert into student_info(学号,姓名,性别,出生日期,家族住址) values
-> ('0001','张青平','男','2000-10-01','衡阳市东风路77号'),
-> ('0002','刘东阳','男','1998-12-09','东阳市八一北路33号'),
-> ('0003','马晓夏','女','1995-05-12','长岭市五一路763号'),
-> ('0004','钱忠理','男','1994-09-23','滨海市洞庭大道279号'),
-> ('0005','孙海洋','男','1995-04-03','长岛市解放路27号'),
-> ('0006','郭小斌','男','1997-11-10','南山市红旗路113号'),
-> ('0007','肖月玲','女','1996-12-07','东方市南京路11号'),
-> ('0008','张玲珑','女','1997-12-24','滨江市新建路97号');
Query OK, 8 rows affected (0.02 sec)
Records: 8 Duplicates: 0 Warnings: 0

mysql> select * from student_info;
+------+--------+------+------------+---------------------+
| 学号 | 姓名 | 性别 | 出生日期 | 家族住址 |
+------+--------+------+------------+---------------------+
| 0001 | 张青平 | 男 | 2000-10-01 | 衡阳市东风路77号 |
| 0002 | 刘东阳 | 男 | 1998-12-09 | 东阳市八一北路33号 |
| 0003 | 马晓夏 | 女 | 1995-05-12 | 长岭市五一路763号 |
| 0004 | 钱忠理 | 男 | 1994-09-23 | 滨海市洞庭大道279号 |
| 0005 | 孙海洋 | 男 | 1995-04-03 | 长岛市解放路27号 |
| 0006 | 郭小斌 | 男 | 1997-11-10 | 南山市红旗路113号 |
| 0007 | 肖月玲 | 女 | 1996-12-07 | 东方市南京路11号 |
| 0008 | 张玲珑 | 女 | 1997-12-24 | 滨江市新建路97号 |
+------+--------+------+------------+---------------------+
8 rows in set (0.19 sec)

mysql> create table curriculum
-> (
-> 课程编号 char(4) not null primary key,
-> 课程名称 varchar(50) null,
-> 学分 int null
-> );
Query OK, 0 rows affected (0.06 sec)

mysql> create table grade
-> (
-> 学号 char(4) not null primary key,
-> 课程编号 char(4) null,
-> 分数 int null
-> );
Query OK, 0 rows affected (0.04 sec)

mysql> insert into curriculum(课程编号,课程名称,学分) values
-> ('0001','计算机应用基础',2),('0002','C语言程序设计',2),
-> ('0003','数据库原理及应用',2),
-> ('0004','英语',4),
-> ('0005','高等数学',4)😉;
Query OK, 5 rows affected (0.01 sec)
Records: 5 Duplicates: 0 Warnings: 0

1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1
mysql> select * from curriculum;
+----------+------------------+------+
| 课程编号 | 课程名称 | 学分 |
+----------+------------------+------+
| 0001 | 计算机应用基础 | 2 |
| 0002 | C语言程序设计 | 2 |
| 0003 | 数据库原理及应用 | 2 |
| 0004 | 英语 | 4 |
| 0005 | 高等数学 | 4 |
+----------+------------------+------+
5 rows in set (0.09 sec)

mysql> insert ignore into grade(学号,课程编号,分数) values
-> ('0001','0001',80),
-> ('0001','0002',91),
-> ('0001','0003',88),
-> ('0001','0004',85),
-> ('0001','0005',77),
-> ('0002','0001',73),
-> ('0002','0002',68),
-> ('0002','0003',80),
-> ('0002','0004',79),
-> ('0002','0005',73),
-> ('0003','0001',84),
-> ('0003','0002',92),
-> ('0003','0003',81),
-> ('0003','0004',82),
-> ('0003','0005',75);
Query OK, 3 rows affected (0.01 sec)
Records: 15 Duplicates: 12 Warnings: 12

mysql> alter table curriculum
-> alter culumn 课程名称 varchar(50) null;
1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '课程名称 varchar(50) null' at line 2
mysql> alter table curriculum
-> drop 课程名称;
Query OK, 0 rows affected (0.21 sec)
Records: 0 Duplicates: 0 Warnings: 0

mysql> select * from curriculum;
+----------+------+
| 课程编号 | 学分 |
+----------+------+
| 0001 | 2 |
| 0002 | 2 |
| 0003 | 2 |
| 0004 | 4 |
| 0005 | 4 |
+----------+------+
5 rows in set (0.06 sec)

mysql> alter table grade
-> modify 分数 decimal(5,2);
Query OK, 3 rows affected (0.09 sec)
Records: 3 Duplicates: 0 Warnings: 0

mysql> alter table student_info
-> add 备注 varchar(50);
Query OK, 0 rows affected (0.05 sec)
Records: 0 Duplicates: 0 Warnings: 0

mysql> create database studb;
Query OK, 1 row affected (0.01 sec)

mysql> use studb;
Database changed
mysql> create table stu as select * from studentadb_info;
1146 - Table 'studb.studentadb_info' doesn't exist
mysql> create table stu
-> select * from student_info;
1146 - Table 'studb.student_info' doesn't exist
mysql> use studentsdb;
Database changed
mysql> create table stu
-> select * from student_info;
Query OK, 8 rows affected (0.08 sec)
Records: 8 Duplicates: 0 Warnings: 0

mysql> use studb;
Database changed
mysql> create database studb
-> ;
1007 - Can't create database 'studb'; database exists
mysql> create table stu
-> as select * from studentsdb,student_info;
1146 - Table 'studb.studentsdb' doesn't exist
mysql> desc stu;
1146 - Table 'studb.stu' doesn't exist
mysql> create table stu
-> as select * from studentsdb.student_info;
Query OK, 8 rows affected (0.05 sec)
Records: 8 Duplicates: 0 Warnings: 0

mysql> desc stu;
+----------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------+-------------+------+-----+---------+-------+
| 学号 | char(4) | NO | | NULL | |
| 姓名 | char(8) | NO | | NULL | |
| 性别 | char(2) | YES | | NULL | |
| 出生日期 | date | YES | | NULL | |
| 家族住址 | varchar(50) | YES | | NULL | |
| 备注 | varchar(50) | YES | | NULL | |
+----------+-------------+------+-----+---------+-------+
6 rows in set (0.06 sec)

mysql> delete from stu where 学号 ='0004';
Query OK, 1 row affected (0.01 sec)

mysql> select * from stu;
+------+--------+------+------------+--------------------+------+
| 学号 | 姓名 | 性别 | 出生日期 | 家族住址 | 备注 |
+------+--------+------+------------+--------------------+------+
| 0001 | 张青平 | 男 | 2000-10-01 | 衡阳市东风路77号 | NULL |
| 0002 | 刘东阳 | 男 | 1998-12-09 | 东阳市八一北路33号 | NULL |
| 0003 | 马晓夏 | 女 | 1995-05-12 | 长岭市五一路763号 | NULL |
| 0005 | 孙海洋 | 男 | 1995-04-03 | 长岛市解放路27号 | NULL |
| 0006 | 郭小斌 | 男 | 1997-11-10 | 南山市红旗路113号 | NULL |
| 0007 | 肖月玲 | 女 | 1996-12-07 | 东方市南京路11号 | NULL |
| 0008 | 张玲珑 | 女 | 1997-12-24 | 滨江市新建路97号 | NULL |
+------+--------+------+------------+--------------------+------+
7 rows in set (0.07 sec)

mysql> update stu
-> select 家庭住址 ='滨江市新建路i96号' where 学号 ='0002';
1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'select 家庭住址 ='滨江市新建路i96号' where 学号 ='0002'' at line 2
mysql> update stu
-> set 家庭住址 ='滨江市新建路i96号' where 学号 ='0002';
1054 - Unknown column '家庭住址' in 'field list'
mysql> select * from stu;
+------+--------+------+------------+--------------------+------+
| 学号 | 姓名 | 性别 | 出生日期 | 家族住址 | 备注 |
+------+--------+------+------------+--------------------+------+
| 0001 | 张青平 | 男 | 2000-10-01 | 衡阳市东风路77号 | NULL |
| 0002 | 刘东阳 | 男 | 1998-12-09 | 东阳市八一北路33号 | NULL |
| 0003 | 马晓夏 | 女 | 1995-05-12 | 长岭市五一路763号 | NULL |
| 0005 | 孙海洋 | 男 | 1995-04-03 | 长岛市解放路27号 | NULL |
| 0006 | 郭小斌 | 男 | 1997-11-10 | 南山市红旗路113号 | NULL |
| 0007 | 肖月玲 | 女 | 1996-12-07 | 东方市南京路11号 | NULL |
| 0008 | 张玲珑 | 女 | 1997-12-24 | 滨江市新建路97号 | NULL |
+------+--------+------+------------+--------------------+------+
7 rows in set (0.12 sec)

mysql> update stu
-> set 家庭住址 ='滨江市新建路i96号' where 学号 ='0002';
1054 - Unknown column '家庭住址' in 'field list'
mysql> update stu
-> set 家族住址 ='滨江市新建路i96号' where 学号 ='0002';
Query OK, 1 row affected (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 0

mysql> select * from stu;
+------+--------+------+------------+-------------------+------+
| 学号 | 姓名 | 性别 | 出生日期 | 家族住址 | 备注 |
+------+--------+------+------------+-------------------+------+
| 0001 | 张青平 | 男 | 2000-10-01 | 衡阳市东风路77号 | NULL |
| 0002 | 刘东阳 | 男 | 1998-12-09 | 滨江市新建路i96号 | NULL |
| 0003 | 马晓夏 | 女 | 1995-05-12 | 长岭市五一路763号 | NULL |
| 0005 | 孙海洋 | 男 | 1995-04-03 | 长岛市解放路27号 | NULL |
| 0006 | 郭小斌 | 男 | 1997-11-10 | 南山市红旗路113号 | NULL |
| 0007 | 肖月玲 | 女 | 1996-12-07 | 东方市南京路11号 | NULL |
| 0008 | 张玲珑 | 女 | 1997-12-24 | 滨江市新建路97号 | NULL |
+------+--------+------+------------+-------------------+------+
7 rows in set (0.14 sec)

mysql> alter table stud
-> drop 备注;
1146 - Table 'studb.stud' doesn't exist
mysql> alter table stud
-> drop culumn 备注;
1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '备注' at line 2
mysql> alter table stud
-> drop column 备注;
1146 - Table 'studb.stud' doesn't exist
mysql> alter table stu
-> drop column 备注;
Query OK, 0 rows affected (0.19 sec)
Records: 0 Duplicates: 0 Warnings: 0

mysql> use studentsdb;
Database changed
mysql> select* from student_info;
+------+--------+------+------------+---------------------+------+
| 学号 | 姓名 | 性别 | 出生日期 | 家族住址 | 备注 |
+------+--------+------+------------+---------------------+------+
| 0001 | 张青平 | 男 | 2000-10-01 | 衡阳市东风路77号 | NULL |
| 0002 | 刘东阳 | 男 | 1998-12-09 | 东阳市八一北路33号 | NULL |
| 0003 | 马晓夏 | 女 | 1995-05-12 | 长岭市五一路763号 | NULL |
| 0004 | 钱忠理 | 男 | 1994-09-23 | 滨海市洞庭大道279号 | NULL |
| 0005 | 孙海洋 | 男 | 1995-04-03 | 长岛市解放路27号 | NULL |
| 0006 | 郭小斌 | 男 | 1997-11-10 | 南山市红旗路113号 | NULL |
| 0007 | 肖月玲 | 女 | 1996-12-07 | 东方市南京路11号 | NULL |
| 0008 | 张玲珑 | 女 | 1997-12-24 | 滨江市新建路97号 | NULL |
+------+--------+------+------------+---------------------+------+
8 rows in set (0.10 sec)

mysql> select 姓名,家族住址,学号from student_info where 学号='0002';
1054 - Unknown column '姓名' in 'field list'
mysql>

posted @ 2023-09-25 16:08  计科李华超  阅读(156)  评论(0)    收藏  举报