Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Brnad New to MySQL: How do I run a simple create script in mysql??

Status
Not open for further replies.

ghewitt

Technical User
Jun 27, 2001
1
US
I have just started using MySQL in a Windows environment. I can run SQL commands from mysql> prompt in DOS and I can use SQL from the prompt to create a database table from the command line. However, I tried running a really simple script to build a table (using exactly same SQL as I used on the command line) as follows:

mysql> @ <create.sql>;

Note: create.sql is in my c:\mysql\bin

but it keeps telling me I have an error in my SQL syntax near --repeates my command --line1.

The SQL inside the sql script (create.sql) is as follows:

Create database01.customers (fname TEXT, Lname TEXT);
Note database01 already exists!

I have tried leaving off the ; at end in the scrtipt also.....Nothing seems to work but like I said if I were to enter the exact same SQL line from the command prompt it creates the table.?????
 
I haven't start using MySQL yet but investigating it.

As in Oracle, do you not have to specify what kind of data structure you are building ie TABLE?

So your command should read;
Create table database01.customers (fname TEXT, Lname TEXT);

But if your original command work at the command line
 
I'm assuming that the database already exists.

In which case, you need to start your script with the &quot;use database&quot; command.

Then make your create statement:

Create customers (fname TEXT, Lname TEXT);
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top