Reputation: 11
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.
Upvotes: 1
Views: 90
Reputation: 409
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');
Upvotes: 0
Reputation: 223
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';
Upvotes: 2