mysql

-- cmd导出数据库
C:\Users\Administrator.97SD-20110326TW> cd C:\ProgramFiles\MySQL\MySQL Server 5.1\bin
C:\ProgramFiles\MySQL\MySQL Server 5.1\bin>mysqldump -u root -p bbs>c:/test.txt
Enter password: **

 

二 修改mysql数据库的编码

--修改bbs数据库为gbk

mysql> alter database bbs default character set gbk collate gbk_bin; 

--修改bbs数据库为utf-8

mysql> alter database bbs default character set utf8 collate utf8_bin; 

--修改表为utf-8

mysql> alter table BBS_BOARD default character set utf8 collate utf8_bin; 

 

 

create database bbs;

use bbs;

CREATE TABLE BBS_USER (
  userid int AUTO_INCREMENT NOT NULL primary key ,
  username varchar(20) NOT NULL,
  password varchar(20) DEFAULT NULL,
  email varchar(20) DEFAULT NULL,
  regtime TIMESTAMP  not null default now(),
  gender char(2),
  UNIQUE (username)
);

-- userid int AUTO_INCREMENT NOT NULL primary key ,AUTO_INCREMENT 自动增长
--Date或DateTime类型是不能使用函数作为默认值的

insert into BBS_USER (username,password,email,gender )
values ('shabao','123',NULL,'男');
insert into BBS_USER (username,password,email,gender )
values ('saboo','123',NULL,'男');

create table BBS_BOARD
(
boardid int not null AUTO_INCREMENT primary key,
boardName varchar(100),
parentId int
);

insert into BBS_BOARD(boardName ,parentId)
values ('校园生活',0);

create table BBS_TOPIC
(
topicId int not null AUTO_INCREMENT primary key,
title varchar(50) not null ,
content varchar(255) not null,
publishTime TIMESTAMP  not null default now(),
modifyTime Date default NULL,
uid int not null,
boardId int not null,
FOREIGN KEY (uid) REFERENCES BBS_USER(userid),
FOREIGN KEY (boardId) REFERENCES BBS_BOARD(boardid)
);

insert into BBS_TOPIC(title,content,uid,boardId)
values('学习是动力','..........................',1,1);

create table BBS_REPLY
(
replyId int not null AUTO_INCREMENT primary key,
title varchar(50) not null ,
content varchar(255) not null,
publishTime TIMESTAMP  not null default now(),
modifyTime Date default NULL,
uid int not null,
topicId int not null,
FOREIGN KEY (uid) REFERENCES BBS_USER(userid),
FOREIGN KEY (topicId) REFERENCES BBS_TOPIC(topicId)
);

insert into BBS_REPLY(title,content,uid,topicId)
values('这样','加油',3,1);


select * from BBS_USER;
select * from BBS_BOARD;
select * from BBS_TOPIC;
select * from BBS_REPLY;

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值