Willimar
Willimar

Reputation: 71

Execution from the statement select * into return error

Can somebody help me?

I am try execute the command below in Oracle 11 and I get this error:

SQL Error [905] [42000]: ORA-00905: keyword not found.

Code:

SELECT * 
INTO SAJ.ETMP_TESTE 
FROM SAJ.ESAJOBJETO O 
WHERE CDOBJETO = 'P800000000J03'

I read the Oracle docs and haven't found any obvious error in my statement.

https://docs.oracle.com/cd/B19306_01/appdev.102/b14261/selectinto_statement.htm

My objective is to create the table ETMP_TESTE with structure from ESAJOBJETO.

I checked user permission and user has permission to action.

Upvotes: 0

Views: 188

Answers (2)

EvilTeach
EvilTeach

Reputation: 28837

This will create an empty table named ETMP_TESTE, with the structure of the SAJ.EASJOBJETO table.

CREATE TABLE ETMP_TESTE AS
SELECT *
FROM SAJ.EASJOBJETO
WHERE 1 = 0;

This does not handle contraints and primary keys and things like that, but it will get you the table structure. The 1 = 0 makes sure no data is copied.

If you need primary keys and the like, look into extracting the DDL for EASJOBJETO. Most SQL IDEs have that functionality built in. You can edit it to correct the table name and run the script and get everything.

Upvotes: 2

ScaisEdge
ScaisEdge

Reputation: 133360

You need create table and not select into for create a table based on the result of a query

CREATE TABLE SAJ.ETMP_TESTE 
AS   SELECT *  
FROM SAJ.ESAJOBJETO O 
WHERE CDOBJETO = 'P800000000J03'

Upvotes: 2

Related Questions