ORA-00928: missing SELECT keyword error occurs when the select or values keyword is missing in the insert statement. If the SELECT keyword is missing while creating a view, the “ORA-00928: missing SELECT keyword” error occurs. In the insert statement, either the select or values keywords should be used. The values keyword is used to insert the table with data. Use the select keyword to insert values from other tables. The error ORA-00928: missing SELECT keyword occurs if none of the keywords are present in the insert statement.
The insert statement should include the value keyword followed by the data to be saved in the table. The error will occur if the insert statement lacks the values keyword or misspells the values keyword. In the insert statement, Oracle looks for the values keyword. If the values keyword is not found, the select keyword is searched. If none of the keywords are found, the error ORA-00928: missing SELECT keyword is thrown.
The Problem
An insert statement is created without the use of the select or values keywords. The insert statement should include either the select or values keywords. The error will be thrown if none of the keywords are available. The inserted data should be added to the values block as comma separated data. If the values block is missing, the insert command will be unable to insert data into the table. The select keyword is used to retrieve data from one table and insert it into another.
insert into employee('id','name') values (1,'test');
Error
insert into employee('id','name') values (1,'test')
Error at Command Line : 5 Column : 22
Error report -
SQL Error: ORA-00928: missing SELECT keyword
00928. 00000 - "missing SELECT keyword"
*Cause:
*Action:
Solution 1
The insert statement specifies a column name and the values to be stored in that column. The column name must not be entered as a string. The error ORA-00928: missing SELECT keyword will be resolved if the enclosed quotes are removed from the column name. The data to be entered into the value should be surrounded by quotes. The column name should not be surrounded by quotes.
Error
insert into employee('id','name') values (1,'test');
Solution
insert into employee(id,name) values (1,'test');
Solution 2
The error ORA-00928: missing SELECT keyword will occur if the values keyword is not present in the insert statement. The values keyword is used to add data in a comma separated format. If the values keyword is not present in the insert statement, the insert statement will be unable to locate the inserted data from the statement. Oracle will generate an error.
Error
insert into employee (1,'test');
Solution
insert into employee values (1,'test');
Solution 3
In the insert statement, the keyword values is misspelt. In the insert statement, look for the values keyword. The inserted data should be placed in the VALUES block as a series of comma-separated values. The error ORA-00928: missing SELECT keyword will occur if the VALUES keyword is misspelt.
Error
insert into employee valus (1,'test');
Solution
insert into employee values (1,'test');
Solution 4
If the select statement is missing from the insert statement, include it in the insert. The select statement retrieves data from one or more tables and inserts it into another table using the insert statement in conjunction with the select statement. The syntax for inserting data from another table using the select statement is demonstrated in the following example.
insert into employee select * from manager;
Solution 5
When creating a view in the database, the select keyword is used to get data from one or more tables. If the select keyword is missing from the CREATE VIEW statement, the view cannot be created because the select sql to fetch the data could not be found. Check the select keyword in the CRATE VIEW statement if you’re creating a view. In the CREATE VIEW statement, include the SELECT keyword. This will resolve the error ORA-00928: missing SELECT keyword.
Error
create view empview as employees.first_name, employees.last_name from employees;
Solution
create view empview as select employees.first_name, employees.last_name from employees;