0% found this document useful (0 votes)
25 views

UID Lab+12

The document outlines SQL operations for managing a MOVIES table, including inserting, updating, and deleting records. It also provides examples of SQL errors encountered when inserting data into SALES and CUSTOMER tables, along with corrections for each error. The corrections involve proper syntax and ensuring the correct number of values are provided for each table's structure.

Uploaded by

toyow26421
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views

UID Lab+12

The document outlines SQL operations for managing a MOVIES table, including inserting, updating, and deleting records. It also provides examples of SQL errors encountered when inserting data into SALES and CUSTOMER tables, along with corrections for each error. The corrections involve proper syntax and ensuring the correct number of values are provided for each table's structure.

Uploaded by

toyow26421
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Exercise

1. Insert 3 rows into the MOVIES table, Below is the MOVIES table structure.

Movie_number number,
Movie_name varchar2(100),
Movie_type varchar2(40),
Movie_release_date date

2. Modify movie release date of movie number 101 from ’12-jan-2015’ to ’14-jan-2015’

3. Delete the row from MOVIES table where the movie name is RUSH HOUR.

Copy and paste the below SQL’s in SQL Developer and run
them, You will get errors and try to correct those errors.
1. INSERT INTO SALES VALUES '12-jan-2015',3456,101,12,3000,10,30,300,30,330)

2. INSERT INTO SALES VALUES ('12-jan-2015',3456,101,12,3000,10,30,300,30)

3. INSERT INTO SALES VALUES ('12-jan-2015' 3456,101,12,3000,10,30,300,30,330)

4. INSERT INTO CUSTOMER VALUES


(101,'JOHNIJOHNIJOHNIJOHNIJOHNIJOHNIJOHNIJOHNIJOHNIJOHNI33','JOSEPH','A',
NULL,NULL,NULL,NULL,NULL)
Answers:
1. INSERT INTO movies VALUES
(
101,
'TERMINATOR',
'ACTION',
'12-JAN-2015'

);

COMMIT;

INSERT INTO movies VALUES


(
102,
'BABIES DAY OUT',
'COMEDY',
'11-FEB-2014'

);

COMMIT;

INSERT INTO movies VALUES


(
103,
'RUSH HOUR',
'ACTION',
'12-DEC-2001'

);

COMMIT;

2. UPDATE movies set movie_release_date = '14-jan-2015'


WHERE movie_number = 101;

COMMIT;

3. DELETE from movies


WHERE movie_name = 'RUSH HOUR';

COMMIT;
Answers for errors:
1) You will get an error “ ORA-00933: SQL command not properly ended” when you run below
SQL statement.

INSERT INTO SALES VALUES '12-jan-2015',3456,101,12,3000,10,30,300,30,330)

It is throwing an error because we missed ( after VALUES. Correct the above SQL
statement by adding ( after VALUES keyword. (This error might be stupid, but these are
the common mistakes we make.)

INSERT INTO SALES VALUES ('12-jan-2015',3456,101,12,3000,10,30,300,30,330)

2) You will get an error “ ORA-00947: not enough values ” when you run below SQL statement.

INSERT INTO SALES VALUES ('12-jan-2015',3456,101,12,3000,10,30,300,30)

It is throwing an error because we have 10 columns in the sales table and we are
inserting only 9 values. So to correct this we need to add the 10 th value (This error might
be stupid, but these are the common mistakes we make.)

INSERT INTO SALES VALUES ('12-jan-2015',3456,101,12,3000,10,30,300,30,330)

3) You will get an error “ ORA-00917: missing comma” when you run below SQL statement.

INSERT INTO SALES VALUES ('12-jan-2015' 3456,101,12,3000,10,30,300,30,330)

It is throwing an error because we missed , after '12-jan-2015'. (This error might be


stupid, but these are the common mistakes we make.)

INSERT INTO SALES VALUES ('12-jan-2015',3456,101,12,3000,10,30,300,30,330)

4) You will get an error “ ORA-12899: value too large for column
TDS_INT"."CUSTOMER"."FIRST_NAME" (actual: 52, maximum: 50) ” when you run below SQL
statement.

INSERT INTO CUSTOMER VALUES


(101,'JOHNIJOHNIJOHNIJOHNIJOHNIJOHNIJOHNIJOHNIJOHNIJOHNI33','JOSEPH','A',
NULL,NULL,NULL,NULL,NULL)

The error is clearly stating that FIRST_NAME length is 50 and you are trying to insert 52
characters. So the solution is either to increase the length of the column FIRST_NAME or
reduce the value you are inserting to less than 50.
ALTER TABLE CUSTOMER MODIFY (FIRST_NAME VARCHAR2(60));

INSERT INTO CUSTOMER VALUES


(101,'JOHNIJOHNIJOHNIJOHNIJOHNIJOHNIJOHNIJOHNIJOHNIJOHNI33','JOSEPH','A',
NULL,NULL,NULL,NULL,NULL)

Or

INSERT INTO CUSTOMER VALUES


(101,'JOHNIJOHNIJOHNIJOHNIJOHNIJOHNIJOHNIJOHNI','JOSEPH','A',
NULL,NULL,NULL,NULL,NULL)

You might also like