日期:2014-05-16  浏览次数:20908 次

执行脚本创建新的数据库和表(初始化)
假设一个小系统,数据库用mysql,数据库名为:library,库里有二个表:book(book_id,book_name),borrower(borrower_id,book_id).系统已经做好了,打包完成,当我发给其他人用的时候,他的电脑上也有mysql,但他机子上没有创建数据库和表,我不想手动去创建,想用脚本让他运行一句代码就完全搞定,执行脚本语句是:mysql   -hlocalhost   -uroot   -p******   <database.sql(当然还有其它方法).请问这个脚本怎么写(database.sql)   里面只要有创建数据库和表就OK了。

------解决方案--------------------
create database library;
use library;
create table book(book_id int not null,book_name varchar(255));
create table borrower(borrower_id int not null, book_id int not null);