1
create table divorced_females 
select cust_id, cust_first_name,cust_last_name, cust_gender, cust_marital_status from customers 
where cust_gender = 'F' and cust_marital_status = 'divorced';

I am getting errors like below:

Error starting at line : 1 in command -
create table divorced_females
select cust_id, cust_first_name,cust_last_name, cust_gender, cust_marital_status from customers
where cust_gender = 'F' and cust_marital_status = 'divorced'

Error report
ORA-00922: missing or invalid option
00922. 00000 - "missing or invalid option"
*Cause:
*Action:

Thank you in advance.

1
  • 7
    Where you trying to create a table from the result of a select statement? Such a statement is called a CTAS statement ("Create Table As Select ...") You are missing the keyword AS between the table name and the keyword select. Commented Oct 9, 2018 at 23:50

2 Answers 2

2

You missing 'AS' after table name.

Try statement below:

create table divorced_females as
select cust_id, cust_first_name,cust_last_name, cust_gender, cust_marital_status 
from customers 
where cust_gender = 'F' and cust_marital_status = 'divorced';
Sign up to request clarification or add additional context in comments.

Comments

0

The syntax for the CREATE TABLE AS statement copying the selected columns is:

CREATE TABLE new_table
  AS (SELECT column_1, column2, ... column_n
  FROM old_table);

So in your case query will be

create table divorced_females  AS 
 (select cust_id, cust_first_name,cust_last_name, cust_gender, cust_marital_status 
 from customers 
where cust_gender = 'F' and cust_marital_status = 'divorced');

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.