Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

SQL Problems

Options
  • 13-11-2010 4:08am
    #1
    Closed Accounts Posts: 2,663 ✭✭✭


    I'm trying to get this Table into Access to see is it ok, but having Problems
    CREATE TABLE Hotel
                 (hotelNo  	VARCHAR(4)    NOT NULL,
                  hotelName	VARCHAR(25),
                  city	VARCHAR(20),
    	     
    PRIMARY KEY (hotelNo));
    
    CREATE TABLE Room
    
                 (roomNo    VARCHAR(4)	NOT NULL,
    	      hotelno	VARCHAR(10),
    	      type	VARCHAR(10),
                  price	VARCHAR(12),
                 
    PRIMARY KEY (roomNo),
    FOREIGN KEY (hotelNo) REFERENCES Hotel(hotelNo));
    
    CREATE TABLE Booking
    
                 (hotelNo   VARCHAR(4)	NOT NULL,
    	      guestNo	VARCHAR(10),
    	      dateFrom	VARCHAR(10),
                  dateTo	VARCHAR(30),
                  roomNo	VARCHAR(16),           
    PRIMARY KEY (guestNo, dateFrom, hotelNo),
    FOREIGN KEY (roomNo) REFERENCES Room(roomNo));
    
    CREATE TABLE Guest
    
                 (guestNo  		VARCHAR(4)	NOT NULL,
    	      guestName		VARCHAR(10),
    	      guestAddress	VARCHAR(10),
                           
    PRIMARY KEY (guestNo));
    
    Commit;
    

    When i run Linux and have SQLite it places the tables but only the Hotel Name, Room and City and not the rest is their something i am missing with my layout?

    Anyhelp will do as this is Wrecking my head trying to get Workbench working not one SQL will Work stating Local Host problems and trying to use Access is killing me.


Comments

  • Registered Users Posts: 23,212 ✭✭✭✭Tom Dunne


    Ok, you are confusing me.

    Are you running this SQL code against an Access database or against and SQLite database? It is not clear.

    What is the exact error you are seeing?


  • Closed Accounts Posts: 2,663 ✭✭✭Cork24


    Not getting error its going to SQLite but the only tables that are going in are that I can see are hotel, room and city the rest are not going in would their be something I'm missing with my keys?

    I done thid code in notepad and copy and paste job


  • Registered Users Posts: 23,212 ✭✭✭✭Tom Dunne


    Cork24 wrote: »
    the rest are not going in would their be something I'm missing with my keys?

    When you say "not going in" do you mean the tables are not created?

    If so, when you run the command, you should get either a "Table created" message, or an error.

    Try running each one individually and see what the result is. Of course, if the table is already created, it will error out.


  • Closed Accounts Posts: 2,663 ✭✭✭Cork24


    Thanks Tom, when i place the whole code in it was only Creating Hotel,
    So i Executed the SQL code for each table on their own and it work had to do the same with Entering some records.


  • Registered Users Posts: 3,721 ✭✭✭E39MSport


    Not familiar with that particular language but the DDL looks dodgy to me. I would have expected the column names to be enclosed in brackets followed by the index clauses etc.

    CREATE TABLE WIBBLE (COL1 CHAR(10), COL2 CHAR (10) ) PI COL1);


  • Advertisement
Advertisement