SQL - ORA-00911 Invalid character on my insertions

123 Views Asked by At

Using Oracle Live SQL. No matter what I do I get ORA-00911 (invalid character). Where did I go wrong in my code?

I've tried changing values in a number of ways, including altering datatypes.

CREATE TABLE Books
(Title varchar(25) NOT NULL,
Author varchar(25) NOT NULL,
PRIMARY KEY (title)
);
INSERT INTO Books (title, author)
VALUES (‘To Kill a Mockingbird’, ‘Harper Lee’);
INSERT INTO Books (title, author)
VALUES (‘The Great Gatsby’, ‘F. Scott Fitzgerald’);
INSERT INTO Books (title, author)
VALUES (‘Dante’s Inferno’, ‘Dante Alighieri’);
INSERT INTO Books (title, author)
VALUES (‘Harry Potter and the Sorcerer’s Stone’, ‘J.K. Rowling’);
INSERT INTO Books (title, author)
VALUES (‘The Hobbit’, ‘J. R. R. Tolkien’);
1

There are 1 best solutions below

6
Ed Bangga On BEST ANSWER

First thing is change to '

Second. This value exceeded the maximum length of your Title column which is 25

VALUES (‘Harry Potter and the Sorcerer’s Stone’, ‘J.K. Rowling’); -> #of chars = 37

Third is escape your single quote by adding ', ‘Dante'’s Inferno’

VALUES (‘Harry Potter and the Sorcerer'’s Stone’, ‘J.K. Rowling’); -> #of chars = 37

try SQLFIDDLE