I'm trying to do a homework assignment for an intro to databases class. We were given a script to use as our database. Here are the first few lines:
我正在尝试为数据库类的介绍做一个家庭作业。我们获得了一个用作数据库的脚本。以下是前几行:
DROP DATABASE hw4;
CREATE DATABASE hw4;
use hw4;
CREATE TABLE Building(
bid int NOT NULL AUTO_INCREMENT,
name varchar(100),
street varchar(100),
city varchar(50),
zipcode char(5),
state char(2),
PRIMARY KEY(bid)
);
When trying to run this, I end up with a syntax error on this line: CREATE DATABASE hw4;
尝试运行时,我最终在此行上出现语法错误:CREATE DATABASE hw4;
Does anyone know how to resolve this issue? I don't know much SQL at all and unfortunately the professor is making us use this script. If it makes a difference I'm trying to run this on windows 7 with MySQL Workbench.
有谁知道如何解决这个问题?我根本不太了解SQL,不幸的是教授让我们使用这个脚本。如果它有所作为我试图在Windows 7上使用MySQL Workbench运行它。
1 个解决方案
#1
You may be given an error because you are trying to drop database that doesen't exist. Try to replace first line with
您可能会收到错误,因为您正在尝试删除不存在的数据库。尝试用第一行替换
DROP DATABASE IF EXISTS hw4;
#1
You may be given an error because you are trying to drop database that doesen't exist. Try to replace first line with
您可能会收到错误,因为您正在尝试删除不存在的数据库。尝试用第一行替换
DROP DATABASE IF EXISTS hw4;