• 全部
  • 问答

下面的.SQL文件导入时出现错误……

xiaopeng0803 2011-01-26 02:07:01
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'go if exists(select * from sysdatabases where name='ManageDB') begin drop da' at line 2

我的数据库版本是5.0.67 请高手指教,以下是.sql文件内容


use master
go
if exists(select * from sysdatabases where name='ManageDB')
begin
drop database ManageDB
end
create database ManageDB
go

use ManageDB
go
--------用户信息--------------
create table userInfo
(
UserId int primary key identity(1,1) , --用户id
UserName varchar(10) not null, --用户名
Gender varchar(4) default '女', --用户性别
UserBirthday datetime , --用户生日
UserPwd varchar(10) , --用户密码
UserEmail varchar(20) , --用户邮件
UserCity varchar(50), --用户所在城市
UserPhone varchar(20),
UserIntegral int default(0) --用户积分
)
go

insert into userInfo values('王丽','女','1988-12-17','123456','wansg11li@163.com','11111','1348465094',50000)
insert into userInfo values('刘兴','男','1986-05-17','456123','lsiuddxing@163.com','1111111','1551201463',20000)
insert into userInfo values('刘一','女','1985-05-19','111111','lsiusdxsing@163.com','11111','1584651423',10000)
insert into userInfo values('刘二','男','1986-05-17','456123','liuxfdsfdsfdsfdsing@163.com','1111111','',20000)
insert into userInfo values('二二','','','456123','liuxifdsfdsafng@163.com','11111111111','',20000)
insert into userInfo values('yiyi','','','456123','liuxdfdsfdsfdsfdsing@163.com','11111111111111111','',0)

select * from userInfo
--------礼品信息--------------

create table GiftsInfo
(
GiftsId int primary key identity(1,1) ,
UserId int foreign key references userInfo(UserId) ,
GiftsName varchar(20) not null,
GiftsIntegral int default(0) not null,
GiftsImg varchar(20) not null
)
go

insert into GiftsInfo values(1,'热水杯',1300,'a.jpg')
insert into GiftsInfo values(1,'克',1000,'a.jpg')
insert into GiftsInfo values(1,'小克',1500,'a.jpg')
insert into GiftsInfo values(2,'热水杯',1300,'a.jpg')
insert into GiftsInfo values(2,'克',1000,'a.jpg')
insert into GiftsInfo values(3,'小快克',1500,'a.jpg')
insert into GiftsInfo values(3,'水杯',1300,'a.jpg')
insert into GiftsInfo values(4,'克',1000,'a.jpg')
insert into GiftsInfo values(4,'小克',1500,'a.jpg')

select * from GiftsInfo
--------最新礼品信息--------------
create table NewsGifts
(
NGId int primary key identity(1,1),
NGName varchar(20) ,
NGIntegral int ,
NGImg varchar(100)
)
go
insert into Newsgifts values('11111111111111',1233,'~/images/mem/lp_thub.gif')
insert into Newsgifts values('11111111111111',1233,'~/images/mem/lp_thub.gif')
insert into Newsgifts values('11111111111111',1233,'~/images/mem/lp_thub.gif')
insert into Newsgifts values('彩11111111111111',1233,'~/images/mem/lp_thub.gif')
insert into Newsgifts values('11111111111111伞',1233,'~/images/mem/lp_thub.gif')
insert into Newsgifts values('fdsfds伞',1233,'~/images/mem/lp_thub.gif')
insert into Newsgifts values('dfsdsfd',1233,'~/images/mem/lp_thub.gif')
insert into Newsgifts values('fdsfds',1233,'~/images/mem/lp_thub.gif')
insert into Newsgifts values('dfsfdsf',1233,'~/images/mem/lp_thub.gif')
insert into Newsgifts values('fdsfdsfds',1000,'a.gif')
select * from NewsGifts

---------------------------------------------------------------------------------------
--declare @UserIntegral
--update userInfo set UserIntegral= 10000 where [UserId] = 1

select convert(char(10),UserBirthday,120) as 'UserBirthday' from UserInfo
---------------------------------------------------------------------------------------

select Username,Gender,UserEmail,UserCity,UserIntegral,convert(char(10),UserBirthday,120) as 'UserBirthday' from UserInfo
---------------------------------------------------------------------------------------

create table UserIntegral
(
Integral_Id int foreign key references userInfo(UserID) identity(1,1),
Integral_Users int
)
go
insert into UserIntegral values(50000)
insert into UserIntegral values(20000)
select * from UserIntegral

select * from userInfo as a join userIntegral as b on a.UserId=b.Integral_Id


--create table GiftsInfo
--(
--giftsId int primary key identity(1,1) not null, --礼品编号
--giftsName varchar(50) not null,
--
--giftsIntegral int not null --礼品积分
--)
...全文
162 点赞 收藏 11
写回复
11 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
然后我还想说一下,你的数据库是从SQL SERVER中导出来的吧?那么多的go,在mysql中貌似也会出错的...
回复
use master
go
if exists(select * from sysdatabases where name='ManageDB')
begin
drop database ManageDB
end
create database ManageDB
go

use ManageDB
go

这些内容,替换为:

DROP DATABASE IF EXISTS `ManageDB`;
CREATE DATABASE `ManageDB` /*!40100 DEFAULT CHARACTER SET utf8 */;
USE `ManageDB`;

回复
skyaspnet 2011-01-26
[Quote=引用 8 楼 xiaopeng0803 的回复:]
引用 7 楼 skyaspnet 的回复:
use master;

master 这个不系统数据库吗,我加上了分号就有如下错误
错误
SQL 查询:

USE MASTER ;




MySQL 返回:

#1049 - Unknown database 'master'
[/Quote]

master这个数据库应该是SQL SERVER的系统数据库,MYSQL并没有,应该要去掉
回复
xiaopeng0803 2011-01-26
[Quote=引用 7 楼 skyaspnet 的回复:]
use master;
[/Quote]
master 这个不系统数据库吗,我加上了分号就有如下错误
错误
SQL 查询:

USE MASTER ;



MySQL 返回:

#1049 - Unknown database 'master'

回复
skyaspnet 2011-01-26
use master;
回复
xiaopeng0803 2011-01-26
[Quote=引用 5 楼 leo_raphael 的回复:]
囧...use master后面不加分隔符,肯定错误...你在use master后面加上分号试试。。
[/Quote]兄弟不对呀
回复
囧...use master后面不加分隔符,肯定错误...你在use master后面加上分号试试。。
回复
xiaopeng0803 2011-01-26
期待解决方法中
回复
xiaopeng0803 2011-01-26
期待解决方法中
回复
feifei_star 2011-01-26
你可用命令导入 source C:/mysql.sql; 一般这样导入不会出现错误
回复
lijpwsw 2011-01-26
mysql 貌似没有 go 用分号分隔就行了吧……
回复
相关推荐
发帖
PHP
创建于2008-08-27

1.9w+

社区成员

“超文本预处理器”,是在服务器端执行的脚本语言,尤其适用于Web开发并可嵌入HTML中。PHP语法利用了C、Java和Perl,该语言的主要目标是允许web开发人员快速编写动态网页。
申请成为版主
帖子事件
创建了帖子
2011-01-26 02:07
社区公告
暂无公告