--閸掔娀娅庨弫鐗堝祦鎼存挸绨眡indou
drop database if exists xindou;
--瀵ゆ椽鍣烽弫鐗堝祦鎼存挸绨眡indou閿涘苯鑻熼幐鍥х暰鐟欙絿鐖滈梿鍡曡礋gb2312
--create database if not exists xindou default character set gb2312;
--瀵ゆ椽鍣烽弫鐗堝祦鎼存挸绨眡indou閿涘苯鑻熼幐鍥х暰鐟欙絿鐖滈梿鍡曡礋utf8
create database if not exists xindou default character set utf8;
--娴h法鏁ら弫鐗堝祦鎼?
use xindou;
--閸掑棛琚悰?
drop table if exists category;
create table if not exists category(
id int not null primary key auto_increment,
cname varchar(20) not null,
parentid int not null default 0,
description varchar(200),
photo blob,
ctype tinyint default 1
) ENGINE=InnoDB;
--瀵ゆ椽鍣烽弫鐗堝祦鎼存挸绨眡indou閿涘苯鑻熼幐鍥х暰鐟欙絿鐖滈梿鍡曡礋gb2312
--create database if not exists xindou default character set gb2312;
--瀵ゆ椽鍣烽弫鐗堝祦鎼存挸绨眡indou閿涘苯鑻熼幐鍥х暰鐟欙絿鐖滈梿鍡曡礋utf8
用source +文件路径 sql文件的内容是一些创建数据库表的语句,并插入了一些内容。
source F:\sheji\final\dbinit\createtable.sql;
内容如下:
drop database if exists xindou;
--瀵ゆ椽鍣烽弫鐗堝祦鎼存挸绨眡indou閿涘苯鑻熼幐鍥х暰鐟欙絿鐖滈梿鍡曡礋gb2312
--create database if not exists xindou default character set gb2312;
--瀵ゆ椽鍣烽弫鐗堝祦鎼存挸绨眡indou閿涘苯鑻熼幐鍥х暰鐟欙絿鐖滈梿鍡曡礋utf8
create database if not exists xindou default character set utf8;
--娴h法鏁ら弫鐗堝祦鎼?
use xindou;
--閸掑棛琚悰?
drop table if exists category;
create table if not exists category(
id int not null primary key auto_increment,
cname varchar(20) not null,
parentid int not null default 0,
description varchar(200),
photo blob,
ctype tinyint default 1
) ENGINE=InnoDB;