I successfully created my table GUEST but i cannot insert a row and get error: ORA-00917: missing comma. I don't see where a comma is missing. Also i am not so sure about the char so i put it as 'F'. I am using oracle database express. Can someone help?
CREATE TABLE GUEST(
GUESTID varchar(14) NOT NULL,
BOOKINGID varchar(4) NOT NULL,
FIRSTNAME varchar(30) NOT NULL,
LASTNAME varchar(30) NOT NULL,
DOB date NOT NULL,
GENDER char NOT NULL,
PHONENUM number(15),
EMAILADDRESS varchar(30) NOT NULL,
ADDRESS varchar(50) NOT NULL,
CONSTRAINT GUESTID PRIMARY KEY (GUESTID),
CONSTRAINT BOOKINGID_FK FOREIGN KEY (BOOKINGID) REFERENCES BOOKING(BOOKINGID)
);
INSERT INTO GUEST VALUES (0271195927397M, 4011, 'Elodie', 'Macquet', TO_DATE('27/11/1995', 'DD/MM/YYYY'), 'F', 23057693013, '[email protected]', 'Curepipe, Mauritius');
CodePudding user response:
The first value is a string, so you have to enclose it into single quotes:
SQL> INSERT INTO GUEST (guestid,
2 bookingid,
3 firstname,
4 lastname,
5 dob,
6 gender,
7 phonenum,
8 emailaddress,
9 address)
10 VALUES ('0271195927397M',
11 4011,
12 'Elodie',
13 'Macquet',
14 TO_DATE ('27/11/1995', 'DD/MM/YYYY'),
15 'F',
16 23057693013,
17 '[email protected]',
18 'Curepipe, Mauritius');
1 row created.
SQL>
Also, note that it is a good idea to always specify all column names you're inserting into.