mysql中的Source语句

示例文件wch.txt存储在D盘wch文件夹下
create database wchst ;
use wchst ;
create table student (
sno char (9) primary key ,
sname char (20) not null ,
ssex char (2) null ,
sage smallint null ,
sdept char (20) null
) ;
create table course (
cno char (4) primary key not null ,
cname char (40) null ,
cpno char (4) null ,
ccredit smallint null ,
foreign key (cpno) references course (cno)
);
create table sc (
sno char (9) not null ,
cno char (4) not null ,
grade smallint null ,
primary key (sno,cno) ,
foreign key (cno) references course (cno),
foreign key (sno) references student (sno)
) ;
delete from sc;
delete from student;
delete from course;
insert into student values(‘200215101’,‘崔深梁’,‘女’,17,‘MA’);
insert into student values(‘200215102’,‘潘声引’,‘女’,18,‘MA’);
insert into student values(‘200215103’,‘冯睛拓’,‘女’,20,‘IS’);
insert into student values(‘200215104’,‘陈钟裳’,‘女’,20,‘IS’);
insert into student values(‘200215105’,‘胡颖笔’,‘男’,20,‘IS’);
insert into student values(‘200215106’,‘梁树得’,‘男’,20,‘MA’);
insert into student values(‘200215107’,‘罗开是’,‘男’,16,‘MA’);
insert into student values(‘200215108’,‘崔贾易’,‘男’,18,‘MA’);
insert into student values(‘200215109’,‘黎拓树’,‘男’,20,‘MA’);
insert into student values(‘200215110’,‘贺声代’,‘男’,17,‘MA’);
insert into student values(‘200215111’,‘方久景’,‘女’,20,‘MA’);
insert into student values(‘200215112’,‘魏沉因’,‘男’,18,‘IS’);
insert into student values(‘200215113’,‘龚愈枫’,‘男’,20,‘MA’);
insert into student values(‘200215114’,‘贾到黎’,‘女’,17,‘MA’);
insert into student values(‘200215115’,‘邹桥梁’,‘女’,20,‘MA’);
insert into student values(‘200215116’,‘钱宿钟’,‘男’,19,‘MA’);
insert into student values(‘200215117’,‘万首情’,‘男’,16,‘MA’);
insert into student values(‘200215118’,‘胡睛音’,‘女’,16,‘IS’);
insert into student values(‘200215119’,‘段的写’,‘女’,20,‘MA’);
insert into student values(‘200215120’,‘谢歌音’,‘男’,16,‘IS’);
insert into student values(‘200215121’,‘薛得显’,‘女’,19,‘MA’);
insert into student values(‘200215122’,‘王得景’,‘女’,16,‘MA’);
insert into student values(‘200215123’,‘姚思岛’,‘女’,17,‘IS’);
insert into student values(‘200215124’,‘郝阔钟’,‘女’,18,‘IS’);
insert into student values(‘200215125’,‘江居到’,‘男’,20,‘MA’);
insert into student values(‘200215126’,‘武深唐’,‘女’,19,‘IS’);
insert into student values(‘200215127’,‘萧桥愈’,‘女’,17,‘MA’);
insert into student values(‘200215128’,‘阎行的’,‘男’,17,‘MA’);
insert into student values(‘200215129’,‘王树桥’,‘男’,18,‘MA’);
insert into student values(‘200215130’,‘林首情’,‘女’,17,‘MA’);
insert into student values(‘200215131’,‘汪青种’,‘男’,20,‘MA’);
insert into student values(‘200215132’,‘白字果’,‘女’,17,‘IS’);
insert into student values(‘200215133’,‘唐据山’,‘男’,18,‘IS’);
insert into student values(‘200215134’,‘吴代还’,‘男’,20,‘MA’);
insert into student values(‘200215135’,‘龙种贾’,‘男’,18,‘IS’);
insert into student values(‘200215136’,‘张贾得’,‘男’,18,‘IS’);
insert into student values(‘200215137’,‘陆颖桥’,‘女’,17,‘IS’);
insert into student values(‘200215138’,‘戴愈很’,‘男’,18,‘IS’);
insert into student values(‘200215139’,‘曾联音’,‘男’,16,‘MA’);
insert into student values(‘200215140’,‘毛音字’,‘女’,17,‘MA’);
insert into student values(‘200215141’,‘秦岛黎’,‘女’,20,‘MA’);
insert into student values(‘200215142’,‘何愈诗’,‘男’,20,‘IS’);
insert into student values(‘200215143’,‘戴种豪’,‘女’,17,‘MA’);
insert into student values(‘200215144’,‘黄阔晨’,‘男’,17,‘MA’);
insert into student values(‘200215145’,‘丁领运’,‘女’,16,‘IS’);
insert into student values(‘200215146’,‘钟带的’,‘男’,16,‘MA’);
insert into student values(‘200215147’,‘高声竟’,‘男’,19,‘IS’);
insert into student values(‘200215148’,‘贺实诗’,‘男’,19,‘MA’);
insert into student values(‘200215149’,‘董境阔’,‘男’,20,‘MA’);
insert into student values(‘200215150’,‘戴还黎’,‘男’,20,‘MA’);
insert into course values(‘1’,‘数据库’,null, 4);
insert into course values(‘2’,‘数学’,null, 2);
insert into course values(‘3’,‘信息系统’,null, 4);
insert into course values(‘4’,‘操作系统’,null, 3);
insert into course values(‘5’,‘数据结构’,null, 4);
insert into course values(‘6’,‘数据处理’,null, 2);
insert into course values(‘7’,‘PASCAL语言’,null, 4);
update course set cpno=‘5’ where cno=‘1’;
update course set cpno=‘1’ where cno=‘2’;
update course set cpno=‘6’ where cno=‘4’;
update course set cpno=‘7’ where cno=‘5’;
update course set cpno=‘6’ where cno=‘7’;
insert into sc values(‘200215101’,‘1’,90);
insert into sc values(‘200215101’,‘2’,96);
insert into sc values(‘200215101’,‘3’,85);
insert into sc values(‘200215102’,‘1’,99);
insert into sc values(‘200215102’,‘2’,83);
insert into sc values(‘200215102’,‘3’,89);
insert into sc values(‘200215102’,‘4’,81);
insert into sc values(‘200215102’,‘5’,97);
insert into sc values(‘200215102’,‘6’,64);
insert into sc values(‘200215102’,‘7’,69);
insert into sc values(‘200215103’,‘1’,71);
insert into sc values(‘200215104’,‘1’,87);
insert into sc values(‘200215105’,‘1’,90);
insert into sc values(‘200215106’,‘1’,84);
insert into sc values(‘200215106’,‘2’,95);
insert into sc values(‘200215106’,‘3’,91);
insert into sc values(‘200215106’,‘4’,79);
insert into sc values(‘200215106’,‘5’,65);
insert into sc values(‘200215106’,‘6’,69);
insert into sc values(‘200215107’,‘1’,81);
insert into sc values(‘200215107’,‘2’,96);
insert into sc values(‘200215108’,‘1’,99);
insert into sc values(‘200215108’,‘2’,97);
insert into sc values(‘200215108’,‘3’,65);
insert into sc values(‘200215109’,‘1’,66);
insert into sc values(‘200215109’,‘2’,88);
insert into sc values(‘200215109’,‘3’,65);
insert into sc values(‘200215109’,‘4’,97);
insert into sc values(‘200215110’,‘1’,71);
insert into sc values(‘200215110’,‘2’,91);
insert into sc values(‘200215110’,‘3’,60);
insert into sc values(‘200215110’,‘4’,86);
insert into sc values(‘200215110’,‘5’,72);
insert into sc values(‘200215110’,‘6’,83);
insert into sc values(‘200215111’,‘1’,96);
insert into sc values(‘200215111’,‘2’,78);
insert into sc values(‘200215111’,‘3’,88);
insert into sc values(‘200215112’,‘1’,85);
insert into sc values(‘200215112’,‘2’,91);
insert into sc values(‘200215112’,‘3’,77);
insert into sc values(‘200215113’,‘1’,92);
insert into sc values(‘200215113’,‘2’,61);
insert into sc values(‘200215113’,‘3’,87);
insert into sc values(‘200215113’,‘4’,91);
insert into sc values(‘200215114’,‘1’,79);
insert into sc values(‘200215114’,‘2’,64);
insert into sc values(‘200215114’,‘3’,81);
insert into sc values(‘200215114’,‘4’,87);
insert into sc values(‘200215114’,‘5’,90);
insert into sc values(‘200215114’,‘6’,62);
insert into sc values(‘200215115’,‘1’,65);
insert into sc values(‘200215115’,‘2’,65);
insert into sc values(‘200215115’,‘3’,99);
insert into sc values(‘200215115’,‘4’,63);
insert into sc values(‘200215115’,‘5’,70);
insert into sc values(‘200215115’,‘6’,98);
insert into sc values(‘200215116’,‘1’,86);
insert into sc values(‘200215116’,‘2’,67);
insert into sc values(‘200215117’,‘1’,84);
insert into sc values(‘200215117’,‘2’,88);
insert into sc values(‘200215117’,‘3’,67);
insert into sc values(‘200215118’,‘1’,62);
insert into sc values(‘200215118’,‘2’,99);
insert into sc values(‘200215119’,‘1’,66);
insert into sc values(‘200215119’,‘2’,80);
insert into sc values(‘200215119’,‘3’,83);
insert into sc values(‘200215119’,‘4’,83);
insert into sc values(‘200215119’,‘5’,81);
insert into sc values(‘200215119’,‘6’,90);
insert into sc values(‘200215120’,‘1’,82);

source d:/wch/wch.txt
show databases;
show tables;
select * from student;

=======================================
运行结果:
mysql> source d:/wch/wch.txt
Query OK, 1 row affected (0.00 sec)

Database changed
Query OK, 0 rows affected (0.12 sec)

Query OK, 0 rows affected (0.14 sec)

Query OK, 0 rows affected (0.15 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 1 row affected (0.02 sec)

Query OK, 1 row affected (0.01 sec)

Query OK, 1 row affected (0.03 sec)

Query OK, 1 row affected (0.03 sec)

Query OK, 1 row affected (0.01 sec)

Query OK, 1 row affected (0.02 sec)

Query OK, 1 row affected (0.01 sec)

Query OK, 1 row affected (0.02 sec)

Query OK, 1 row affected (0.02 sec)

Query OK, 1 row affected (0.01 sec)

Query OK, 1 row affected (0.01 sec)

Query OK, 1 row affected (0.01 sec)

Query OK, 1 row affected (0.01 sec)

Query OK, 1 row affected (0.02 sec)

Query OK, 1 row affected (0.02 sec)

Query OK, 1 row affected (0.02 sec)

Query OK, 1 row affected (0.01 sec)

Query OK, 1 row affected (0.01 sec)

Query OK, 1 row affected (0.02 sec)

Query OK, 1 row affected (0.01 sec)

Query OK, 1 row affected (0.02 sec)

Query OK, 1 row affected (0.04 sec)

Query OK, 1 row affected (0.03 sec)

Query OK, 1 row affected (0.01 sec)

Query OK, 1 row affected (0.02 sec)

Query OK, 1 row affected (0.01 sec)

Query OK, 1 row affected (0.02 sec)

Query OK, 1 row affected (0.02 sec)

Query OK, 1 row affected (0.01 sec)

Query OK, 1 row affected (0.01 sec)

Query OK, 1 row affected (0.01 sec)

Query OK, 1 row affected (0.02 sec)

Query OK, 1 row affected (0.01 sec)

Query OK, 1 row affected (0.02 sec)

Query OK, 1 row affected (0.07 sec)

Query OK, 1 row affected (0.09 sec)

Query OK, 1 row affected (0.11 sec)

Query OK, 1 row affected (0.05 sec)

Query OK, 1 row affected (0.05 sec)

Query OK, 1 row affected (0.03 sec)

Query OK, 1 row affected (0.01 sec)

Query OK, 1 row affected (0.02 sec)

Query OK, 1 row affected (0.02 sec)

Query OK, 1 row affected (0.02 sec)

Query OK, 1 row affected (0.01 sec)

Query OK, 1 row affected (0.01 sec)

Query OK, 1 row affected (0.02 sec)

Query OK, 1 row affected (0.02 sec)

Query OK, 1 row affected (0.02 sec)

Query OK, 1 row affected (0.01 sec)

Query OK, 1 row affected (0.01 sec)

Query OK, 1 row affected (0.01 sec)

Query OK, 1 row affected (0.01 sec)

Query OK, 1 row affected (0.02 sec)

Query OK, 1 row affected (0.01 sec)

Query OK, 1 row affected (0.02 sec)

Query OK, 1 row affected (0.02 sec)

Query OK, 1 row affected (0.02 sec)
Rows matched: 1 Changed: 1 Warnings: 0

Query OK, 1 row affected (0.02 sec)
Rows matched: 1 Changed: 1 Warnings: 0

Query OK, 1 row affected (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 0

Query OK, 1 row affected (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 0

Query OK, 1 row affected (0.02 sec)
Rows matched: 1 Changed: 1 Warnings: 0

Query OK, 1 row affected (0.01 sec)

Query OK, 1 row affected (0.01 sec)

Query OK, 1 row affected (0.05 sec)

Query OK, 1 row affected (0.01 sec)

Query OK, 1 row affected (0.02 sec)

Query OK, 1 row affected (0.01 sec)

Query OK, 1 row affected (0.02 sec)

Query OK, 1 row affected (0.01 sec)

Query OK, 1 row affected (0.02 sec)

Query OK, 1 row affected (0.01 sec)

Query OK, 1 row affected (0.02 sec)

Query OK, 1 row affected (0.01 sec)

Query OK, 1 row affected (0.01 sec)

Query OK, 1 row affected (0.01 sec)

Query OK, 1 row affected (0.01 sec)

Query OK, 1 row affected (0.03 sec)

Query OK, 1 row affected (0.28 sec)

Query OK, 1 row affected (0.34 sec)

Query OK, 1 row affected (0.53 sec)

Query OK, 1 row affected (0.02 sec)

Query OK, 1 row affected (0.01 sec)

Query OK, 1 row affected (0.02 sec)

Query OK, 1 row affected (0.01 sec)

Query OK, 1 row affected (0.01 sec)

Query OK, 1 row affected (0.01 sec)

Query OK, 1 row affected (0.01 sec)

Query OK, 1 row affected (0.01 sec)

Query OK, 1 row affected (0.74 sec)

Query OK, 1 row affected (0.08 sec)

Query OK, 1 row affected (0.03 sec)

Query OK, 1 row affected (0.01 sec)

Query OK, 1 row affected (0.02 sec)

Query OK, 1 row affected (0.01 sec)

Query OK, 1 row affected (0.01 sec)

Query OK, 1 row affected (0.01 sec)

Query OK, 1 row affected (0.02 sec)

Query OK, 1 row affected (0.02 sec)

Query OK, 1 row affected (0.02 sec)

Query OK, 1 row affected (0.02 sec)

Query OK, 1 row affected (0.02 sec)

Query OK, 1 row affected (0.02 sec)

Query OK, 1 row affected (0.02 sec)

Query OK, 1 row affected (0.02 sec)

Query OK, 1 row affected (0.02 sec)

Query OK, 1 row affected (0.02 sec)

Query OK, 1 row affected (0.01 sec)

Query OK, 1 row affected (0.01 sec)

Query OK, 1 row affected (0.01 sec)

Query OK, 1 row affected (0.01 sec)

Query OK, 1 row affected (0.01 sec)

Query OK, 1 row affected (0.02 sec)

Query OK, 1 row affected (0.02 sec)

Query OK, 1 row affected (0.01 sec)

Query OK, 1 row affected (0.02 sec)

Query OK, 1 row affected (0.01 sec)

Query OK, 1 row affected (0.02 sec)

Query OK, 1 row affected (0.01 sec)

Query OK, 1 row affected (0.02 sec)

Query OK, 1 row affected (0.01 sec)

Query OK, 1 row affected (0.02 sec)

Query OK, 1 row affected (0.01 sec)

Query OK, 1 row affected (0.02 sec)

Query OK, 1 row affected (0.01 sec)

Query OK, 1 row affected (0.02 sec)

Query OK, 1 row affected (0.01 sec)

Query OK, 1 row affected (0.02 sec)

Query OK, 1 row affected (0.01 sec)

Query OK, 1 row affected (0.02 sec)

Query OK, 1 row affected (0.02 sec)

Query OK, 1 row affected (0.02 sec)

mysql> show databases;
±-------------------+
| Database |
±-------------------+
| information_schema |
| mysql |
| performance_schema |
| st |
| test |
| wchst |
±-------------------+
6 rows in set (0.00 sec)

mysql> show tables;
±----------------+
| Tables_in_wchst |
±----------------+
| course |
| sc |
| student |
±----------------+
3 rows in set (0.00 sec)

mysql> select * from student;
±----------±-------±-----±-----±------+
| sno | sname | ssex | sage | sdept |
±----------±-------±-----±-----±------+
| 200215101 | 崔深梁 | 女 | 17 | MA |
| 200215102 | 潘声引 | 女 | 18 | MA |
| 200215103 | 冯睛拓 | 女 | 20 | IS |
| 200215104 | 陈钟裳 | 女 | 20 | IS |
| 200215105 | 胡颖笔 | 男 | 20 | IS |
| 200215106 | 梁树得 | 男 | 20 | MA |
| 200215107 | 罗开是 | 男 | 16 | MA |
| 200215108 | 崔贾易 | 男 | 18 | MA |
| 200215109 | 黎拓树 | 男 | 20 | MA |
| 200215110 | 贺声代 | 男 | 17 | MA |
| 200215111 | 方久景 | 女 | 20 | MA |
| 200215112 | 魏沉因 | 男 | 18 | IS |
| 200215113 | 龚愈枫 | 男 | 20 | MA |
| 200215114 | 贾到黎 | 女 | 17 | MA |
| 200215115 | 邹桥梁 | 女 | 20 | MA |
| 200215116 | 钱宿钟 | 男 | 19 | MA |
| 200215117 | 万首情 | 男 | 16 | MA |
| 200215118 | 胡睛音 | 女 | 16 | IS |
| 200215119 | 段的写 | 女 | 20 | MA |
| 200215120 | 谢歌音 | 男 | 16 | IS |
| 200215121 | 薛得显 | 女 | 19 | MA |
| 200215122 | 王得景 | 女 | 16 | MA |
| 200215123 | 姚思岛 | 女 | 17 | IS |
| 200215124 | 郝阔钟 | 女 | 18 | IS |
| 200215125 | 江居到 | 男 | 20 | MA |
| 200215126 | 武深唐 | 女 | 19 | IS |
| 200215127 | 萧桥愈 | 女 | 17 | MA |
| 200215128 | 阎行的 | 男 | 17 | MA |
| 200215129 | 王树桥 | 男 | 18 | MA |
| 200215130 | 林首情 | 女 | 17 | MA |
| 200215131 | 汪青种 | 男 | 20 | MA |
| 200215132 | 白字果 | 女 | 17 | IS |
| 200215133 | 唐据山 | 男 | 18 | IS |
| 200215134 | 吴代还 | 男 | 20 | MA |
| 200215135 | 龙种贾 | 男 | 18 | IS |
| 200215136 | 张贾得 | 男 | 18 | IS |
| 200215137 | 陆颖桥 | 女 | 17 | IS |
| 200215138 | 戴愈很 | 男 | 18 | IS |
| 200215139 | 曾联音 | 男 | 16 | MA |
| 200215140 | 毛音字 | 女 | 17 | MA |
| 200215141 | 秦岛黎 | 女 | 20 | MA |
| 200215142 | 何愈诗 | 男 | 20 | IS |
| 200215143 | 戴种豪 | 女 | 17 | MA |
| 200215144 | 黄阔晨 | 男 | 17 | MA |
| 200215145 | 丁领运 | 女 | 16 | IS |
| 200215146 | 钟带的 | 男 | 16 | MA |
| 200215147 | 高声竟 | 男 | 19 | IS |
| 200215148 | 贺实诗 | 男 | 19 | MA |
| 200215149 | 董境阔 | 男 | 20 | MA |
| 200215150 | 戴还黎 | 男 | 20 | MA |
±----------±-------±-----±-----±------+
50 rows in set (0.00 sec)

你可能感兴趣的:(MySQL笔记,mysql)