0

I am an online student and have just started to learn SQL. I am doing an exercise where I have to create a new database with the following command in Apache Open Office 4.1.3.

CREATE TABLE "tbl_customers" ("customer_id" INTEGER IDENTITY, "first_name" VARCHAR(50), "last_name" VARCHAR(50), "phone" VARCHAR(25), "email" VARCHAR(30), PRIMARY KEY ( "customer_id"));

syntax error, unexpected NAME, expecting ')' or ','

This is a command that an instructor uses on her computer on the other side of the world, in the same version of Open Office, and it executes for her. I have uninstalled, restarted the computer and reinstalled the program, checked the commas and apostrophes, but whatever I try, it keeps giving me the above error.

Brad Solomon
  • 38,521
  • 31
  • 149
  • 235
Krisztian Toth
  • 57
  • 3
  • 13
  • This command runs fine in MS SQL Server! You can try taking out all of the double quotes as they aren't necessary in this example. Your syntax might be a little different depending on the type of database server you are using, check out this link: https://www.w3schools.com/sql/sql_primarykey.asp – Lucky Sep 20 '17 at 15:30
  • Do you have code before or after this? That might be where your issue is... – Lucky Sep 20 '17 at 15:31
  • Hi Lucky. Thank you. No, I don't have code before or after this. This is literally the first command I need to run. I actually tried removing the double quotes (without success) but as far as I know Open Office Base needs them. – Krisztian Toth Sep 20 '17 at 15:36
  • Try removing IDENTITY from there – Lucky Sep 20 '17 at 15:59
  • The error message changed to: 1: The query can not be executed. It is too complex. – Krisztian Toth Sep 20 '17 at 16:04
  • If that works your server wants a seed and increment, like IDENTITY(1,1). See this link: https://learn.microsoft.com/en-us/sql/t-sql/statements/create-table-transact-sql-identity-property – Lucky Sep 20 '17 at 16:05
  • Sorry, it didn't work. I get the original error message if I add the increment. – Krisztian Toth Sep 20 '17 at 16:21
  • Sorry man, I'm out of ideas! – Lucky Sep 20 '17 at 16:23

1 Answers1

0

It should work. Did you run the command by going to Tools -> SQL? Here are step by step instructions.

  1. Create a new Base file. For example from Writer, go to File -> New -> Database.
  2. Create a new database should be marked by default. This will use the HSQLDB 1.8 engine in an embedded setup (not good for real work, but okay for testing.)
  3. Press Next, then mark No, do not register the database. Or mark Yes if using it from Calc. Be sure that Open the database for editing is marked, then press Finish.
  4. Save as "New Database.odb" or give it a different name.
  5. Go to Tools -> SQL and paste the command. Then press Execute. execute
  6. Close and then go to View -> Refresh Tables to show the "tbl_customers" table.
Jim K
  • 12,824
  • 2
  • 22
  • 51
  • I followed the above but it still gives the same error message. I have been using the the Tools --> SQL command all along. – Krisztian Toth Sep 21 '17 at 13:45
  • Screenshot: https://drive.google.com/open?id=0B1R4nPBfoahaNHA5WWxGa19rV1k – Krisztian Toth Sep 21 '17 at 13:53
  • Well, that's strange. I tested this with the English-US 32-bit AOO installer, running on Windows 10 (64-bit system, 64-bit processor). What operating system and language did you [download](https://www.openoffice.org/download/)? I recommend a 32-bit installer. One more suggestion: Try LibreOffice; it's newer and better in many ways. – Jim K Sep 21 '17 at 15:55
  • I downloaded Windows 32 bit English and running it on a 64 bit Windows 7. I'll give libre office a try. – Krisztian Toth Sep 21 '17 at 18:57
  • 1
    Thank you @Jim K, Libre Office runs the command just fine. Something with my Apache OpenOffice was really not working. – Krisztian Toth Sep 21 '17 at 19:18