MySQL执行外部sql脚本

时间:2023-03-08 16:35:43

1:~/mysql_test/test.sql

  1 create table student(
2 sno int not null primary key auto_increment,
3 sname varchar(20) not null
4 ) engine=MyISAM default charset=utf8;

2:在控制台下执行。mysql> source ~/mysql_test/test.sql

Query OK, 0 rows affected (0.07 sec)

3:显示表student 的建表语句:mysql> show create table student\G

*************************** 1. row ***************************
Table: student
Create Table: CREATE TABLE `student` (
`sno` int(11) NOT NULL AUTO_INCREMENT,
`sname` varchar(20) NOT NULL,
PRIMARY KEY (`sno`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8
1 row in set (0.00 sec)