How can I insert my code and make it work when getting errors?

Viewed 43

Create a table named ADVENTURE_TRIP. The table has the same structure as the TRIP table shown in Figure 3-39 except the TRIP_NAME column should use the VARCHAR data type and the DISTANCE and MAX_GRP_SIZE columns should use the NUMBER data type. Execute the command to describe the layout and characteristics of the ADVENTURE_TRIP table.

I then use the code (this worked and made the table)

CREATE TABLE ADVENTURE_TRIP
(
    TRIP_ID DECIMAL(3, 0) PRIMARY KEY,
    TRIP_NAME VARCHAR(75),
    START_LOCATION CHAR(50),
    STATE CHAR(2),
    DISTANCE NUMBER(4,0),
    MAX_GRP_SIZE NUMBER(4,0),
    TYPE CHAR(20),
    SEASON CHAR(20)
);

I then need to "a) Add the following row to the ADVENTURE_TRIP table:

trip ID: 45; trip name: Jay Peak; start location: Jay; state: VT; distance: 8; maximum group size: 8; type: Hiking; season: Summer

b) Display the contents of the ADVENTURE_TRIP table. "

So I use the code

INSERT INTO 'Adventure_Trip' ('TRIP_ID', 'TRIP_NAME', 'START_LOCATION', 'STATE', 
                              'DISTANCE', 'MAX_GRP_SIZE', 'TYPE', 'SEASON')
VALUES (45, 'Jay Peak', 'Jay', 'VT', 8, 8, 'HIKING', 'SUMMER');

but it will not work AT ALL. It says that the table name is wrong even though I've double checked a million times. No clue on what to do now.

1 Answers

Single quotes (') denote string literals in SQL. Object names, such as tables and columns, should not be surrounded by them. Remove the quotes from the table name and column list in your insert statement and you should be OK:

INSERT INTO Adventure_Trip
(TRIP_ID, TRIP_NAME, START_LOCATION, STATE, DISTANCE, MAX_GRP_SIZE, TYPE, SEASON)
VALUES
(45, 'Jay Peak', 'Jay', 'VT', 8, 8, 'HIKING', 'SUMMER');
Related