Creating a table using SELECT
I want to create a copy of an existing table. What is the proper SQL statement that will execute this?
Note that constraints, indexes and triggers are not copied if you use this method. You will have to create statements to do that. A tool like TOAD makes it easy to do that.
You can also use dbms_metadata package to create the table definition.
SQL> SELECT DBMS_METADATA.GET_DDL('TABLE','EMP','SCOTT') FROM DUAL;
CREATE TABLE "SCOTT"."EMP"
( "EMPNO" NUMBER(4,0),
"ENAME" VARCHAR2(10),
"JOB" VARCHAR2(9),
"MGR" NUMBER(4,0),
"HIREDATE" DATE,
"SAL" NUMBER(7,2),
"COMM" NUMBER(7,2),
"DEPTNO" NUMBER(2,0),
CONSTRAINT "PK_EMP" PRIMARY KEY ("EMPNO")
USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
TABLESPACE "SYSTEM" ENABLE,
CONSTRAINT "FK_DEPTNO" FOREIGN KEY ("DEPTNO")
REFERENCES "SCOTT"."DEPT" ("DEPTNO") ENABLE
) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
TABLESPACE "SYSTEM"
Similar Messages
-
Create physical table using select in repository
Hi Gurus,
Can we create Physical table in OBIEE 11.1.1.6 repository using stored procedure and select?
How is the right syntax?
Thank you so much
JOEHi,
Yes. physical layer just select and put it like below
for example,
select field1, field2, . field_n
from tables
UNION
select field1, field2, . field_n
from tables;
http://gerardnico.com/wiki/dat/obiee/opaque_view
http://www.clearpeaks.com/blog/oracle-bi-ee-11gusing-select_physical-in-obiee-11g
http://allaboutobiee.blogspot.com/2012/05/obiee-11g-deployundeploy-view-in.html
Thanks
Deva -
Hi Friends,
I am using Oracle 8.1.6 Server, & facing problems while retrieving data from a PL/SQL Table:
CREATE or REPLACE PROCEDURE test_proc IS
TYPE tP2 is TABLE of varchar2(10); --declared a collection
dt2 tP2 := tP2('a','b','c');
i NUMBER(8);
begin
SELECT COUNT(*) INTO i FROM TABLE(CAST(dt2 as tP2));
DBMS_OUTPUT.PUT_LINE('**'||i);
end;
While executing the above procedure, I encountered foll. error:
ERROR at line 1:
ORA-00600: internal error code, arguments: [15419], [severe error during PL/SQL execution], [], [],
ORA-06544: PL/SQL: internal error, arguments: [pfrrun.c:pfrbnd1()], [], [], [], [], [], [], []
ORA-06553: PLS-801: internal error [0]
Can anyone please help me, where the problem is??
Is it Possible to retrieve data from PL/SQL TABLE using SELECT statement? & How ?
Thanks in advance.
Best Regards,
Jay Raval.Thanks Roger for the Update.
It means that have to first CREATE TYPE .. TABLE in database then only I can fire a Select statement on that TYPE.
Actually I wanted to fire a Select statement on the TABLE TYPE, defined & declared in PLSQL stored procedure using DECLARE TYPE .. TABLE & not using CREATE TYPE .. TABLE.
I was eager to know this, because my organization is reluctant in using CREATE TYPE .. TABLE defined in the database, so I was looking out for another alternative to access PL/SQL TABLE using Select statement without defining it database. It would have been good if I could access a PLSQL TABLE using Select statement Declared locally in the stored procedure.
Can I summarize that to access a PL/SQL TABLE using SELECT statement, I have to first CREATE TYPE .. TABLE?
If someone have any other idea on this, please do let me know.
Thanks a lot for all help.
Best Regards,
Jay Raval.
You have to define a database type...
create type tP2 is table of varchar2(10)
CREATE OR REPLACE PROCEDURE TEST_PROC
IS
dt2 tP2 := tP2('a','b','c');
i NUMBER(8);
begin
SELECT COUNT(*) INTO i FROM TABLE(CAST (dt2 AS tP2));
DBMS_OUTPUT.PUT_LINE('**'||i);
end;
This will work.
Roger -
FETCHING VALUES IN MULTI RECORD BLOCK FROM ANOTHER TABLE USING SELECT STATEMENT.
Hi,
I have one multi record block in which i want to fetch values
(more then one record) from another table using select statement
IN KEY NEXT ITEM.I am getting following error.
ORA-01422: exact fetch returns more than requested number of rows
Thanks in advance.In your case I see no reason to use non-database block and to try to populate it from a trigger with a query, instead of using the default forms functionality where you can associate the block and the fields with table, create where clause using bind variables and simply use execute_query() build-in to populate the block. The power of the forms is to use their build-in functionality to interact with the database.
Also, you can base your block on a query, not on a table and you dynamically change this query using set_block_property() build-in. You can use any dynamic queries (based on different data sources) and you simply need to control the column's data type, the number of the columns and their aliases. Something like creating inline views as a block data source.
However, you can replace the explicit cursor with implicit one like
go_block('non_db_block_name');
first_record();
FOR v_tab IN (SELECT *
FROM tab
WHERE col_name = :variable)
LOOP
:non_db_block_name.field1 := v_tab.col1;
:non_db_block_name.field2 := v_tab.col2;
next_record();
END LOOP; -
Creating Physical table as select in the .rpd
When creating a physical table as a select we can write the SQL statement like SELECT A,B,C... FROM xxx etc.
Trouble is that we then have to go the tab COLUMNS and define each column... This is kind of very error prone and lots of work...
Pls. is there a way to somehow leverage the columns alreaday defined in the PHYSICAL TABLE ?
Txs. for any help.
AntonioHi Antonio,
You didnt catch me..
1)Open actual rpd and create a view using select query, do not add any columns.
2) Create view in dev db.
3) Create a new rpd file import the view into the physical layer.
4) Select columns from step3 and copy
5) paste in the actual rpd on selecting the 'select query' object
you are good to go.
This wold help you with all columns and their datatypes.
Hope this helps.
Cheers,
SVee -
How to create a table using subform if lifecycle designer 7.1 not availabl
hi,
plis tell me how to create a table because i am using adobe lifecycle 6.1 and in the library
there is no object for table..
also tell me that if i have adobe lifecycle designer then which is better option and why?
use table from library directly or create a table using subform...Hi Sweta,
Create the interface attributes of type string and xtring type.
Create node in the context of type graphics. bind the interface fields to the graphic node context element properties -
Graphic content, field of xzstring type and mimetype to be string/any char data type of suitable length.
In layout drag and drop the image field and bind it to the graphic element.
In yoour report programme-
do the code as berlow to pass the graphic data -
<i>CALL METHOD cl_ssf_xsf_utilities=>get_bds_graphic_as_bmp
EXPORTING
p_object = 'GRAPHICS'
p_name = '<mime type graphic name>'
p_id = 'BMAP'
p_btype = 'BCOL' "BMON if monochrome
RECEIVING
p_bmp = w_binary
EXCEPTIONS
not_found = 1
internal_error = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.</i>
in the call <form function module>
pass the inerface values for
xstring (graphic field) to be w_binary (import parameter of the previous method)
and mime type to be 'image/bmp'.
This would work.
Hope fully you may be able to see a tutorial on this soon ;).
- anto. -
How to create a table using Text Layout Framework?
How to create a table using Text Layout Framework? I meen real tables - like in HTML.
Cell as indipendant TLF should work, I have created my table using same approach and works fine for me ... this is where it is
http://apps.live-documents.com/docs/openWebDoc.do?docId=1480607
Regards
Raf -
How to create a table using polish
I am able to show all the database records in table form but i want to edit a particular cell of the table, how to do that. thanks in advance.
Cell as indipendant TLF should work, I have created my table using same approach and works fine for me ... this is where it is
http://apps.live-documents.com/docs/openWebDoc.do?docId=1480607
Regards
Raf -
I created a table using the ranking field and now I need to delete the "dots/buttons" and turn them into text fields, is this possible?
It sounds like what you are trying to do is edit the choices in a likert field to something other than the default radio button. This is not something that you can do in Formscentral at this time.
Andrew -
Create temporary Tables using SQL
Hello,
I'm wondering if SAP allows the creation of new Tables without SDK objects,
I want to create temporary tables using SQL scripts an compile them when an specific addon is connected and erase them when the addon disconnects,
Do you think this is allowed?.
thanks,
GabrielaYou could always have a second DB to create your temp tables in. This is the way I've done this, as well as created my own views and stored procedures in it. No updating of the primary table necessary. The way I named things was:
Company_DB - Company Database
Company_DB-Extern - My own stuff
Then, in sap, you can just do [Company_DB-Extern]..Object to call it, or you do the same from withing your project. -
CREATE MULTIPLE TABLES USING BATCH FILE OR ANYOTHER MODE
Dear Legends,
I want to create Multiple table at a single stroke in oracle sql developer or sql*plus using any mode like batch file or sql files...
I dont know the exact mode and how to create it please guide me..I want to learn more about this since am a DBA Beginner..
Any kind of help would be appreciated more...Thanks in Advance
Regards,
Karthik..Hi Everyone,
According to your suggestion I did everything and all works fine yesterday... But today the same script.bat file is not opening sqlplus...
as soon as I double click the bat file it opens the prompt and it shows upto the copyright ..oracle all rights reserved. sql> prompt is not visible or upto that it strucks... please help me..
My SCRIPT.BAT
@echo off
set ORACLE_SID=VESS
set PATH=%oracle_home%\bin\
sqlplus scott/tiger@VESS @test.sql
echo "Disconnected"
My test.sql
select * from tab;
Please help me...
Regards,
Karthik.. -
I am unable to create a table using procedure..
Hi everyone,
I have given CREATE ANY TABLE privilege to user A and wants to insert data into TAB1 in schema B using a procedure "INSERT INTO B.TAB1 AS SELECT * FROM A.TAB1" but it shows the message--
PL/SQL: ORA-01031: insufficient privileges
Which privilege user A need to do the above task.
Thanks,
AbhijeetSQL> create user a identified by a;
SQL>create user b identified by b;
SQL> grant connect,resource to a;
Grant succeeded.
SQL> grant connect,resource to b;
Grant succeeded.
SQL> grant create any table to a;
Grant succeeded.
SQL> conn a/a
Connected.
SQL> create table tab1 (id number);
Table created.
SQL> insert into tab1 values (1);
1 row created.
SQL> commit;
Commit complete.
SQL> conn b/b
Connected.
SQL> create table tab1 (id number);
Table created.
SQL> insert into b.tab1 select * from tab1;
insert into b.tab1 select * from tab1
ERROR at line 1:
ORA-01031: insufficient privileges
SQL> conn sys as sysdba
Enter password:
Connected.
SQL> grant insert any table to a;
Grant succeeded.
SQL> conn a/a
Connected.
SQL> insert into b.tab1 select * from tab1;
1 row created.
So you need to grant “*insert any table* “ privileges to a;
regards
Liakat hossain -
How to create new table using pertioned table
hi,
i am using a partitioned table , now i want to craet a new table with same structure of my existing partitioned table.
so can i use this syntax
create table abc_new as
select * from my_partitioned_table
where 1=2;
if i use this syntax would it make same structure of my existing partitioned table ?
and
when
we use syntax like
create table abc_new as
select * from my_partitioned_table
where 1=2;
so would it make also indexing on new table to if old table exists ? if not so how can we create that indexing too at time of running this syntax ?
reagrdsNo.
Although the command would create a new table with the same column names and datatypes, it would NOT be a partitioned table. You must explicitly specify the PARTITION BY clause and Partition definitions when creating the table.
Similarly, index definitions are not copied automatically. You must explicitly run the CREATE INDEX statements (which you can generate from the source using DBMS_METADATA.GET_DDL or using any other tools/utilities).
(However, if you use Export-Import -- e.g. importing to another schema or to another database, it would create a partitoned table with the same name and with the same index definitions).
Hemant K Chitale -
Create Partition table using CTAS
Hi there,
Is it possible to create a duplicate partition table from a existing partition table using CTAS method? If yes, could you explain how ?If No , how to make a duplicate partition table?
Thanks in advance?
Rajesh MarathEasily:
conn / as sysdba
CREATE TABLESPACE part1
DATAFILE 'c:\temp\part01.dbf' SIZE 50M
BLOCKSIZE 8192
EXTENT MANAGEMENT LOCAL UNIFORM SIZE 256K
SEGMENT SPACE MANAGEMENT AUTO
ONLINE;
CREATE TABLESPACE part2
DATAFILE 'c:\temp\part02.dbf' SIZE 50M
BLOCKSIZE 8192
EXTENT MANAGEMENT LOCAL UNIFORM SIZE 256K
SEGMENT SPACE MANAGEMENT AUTO
ONLINE;
CREATE TABLESPACE part3
DATAFILE 'c:\temp\part03.dbf' SIZE 50M
BLOCKSIZE 8192
EXTENT MANAGEMENT LOCAL UNIFORM SIZE 256K
SEGMENT SPACE MANAGEMENT AUTO
ONLINE;
ALTER USER uwclass QUOTA UNLIMITED ON part1;
ALTER USER uwclass QUOTA UNLIMITED ON part2;
ALTER USER uwclass QUOTA UNLIMITED ON part3;
conn uwclass/uwclass
CREATE TABLE hash_part (
prof_history_id NUMBER(10),
person_id NUMBER(10) NOT NULL,
organization_id NUMBER(10) NOT NULL,
record_date DATE NOT NULL,
prof_hist_comments VARCHAR2(2000))
PARTITION BY HASH (prof_history_id)
PARTITIONS 3
STORE IN (part1, part2, part3);
CREATE TABLE duplicate_hash_part
PARTITION BY HASH (prof_history_id)
PARTITIONS 3
STORE IN (part1, part2, part3) AS
SELECT * FROM hash_part;Follow the same logic for list and range partitions -
Create target table using ODI model
Hi all,
I am new to ODI. I am trying export RDBMS table to RDBMS table from source to target.
whether we need to create target table structure in trg schema or we can create using obi trg model by selecting new datastore.
In owb while loading target tables are created and data will be loaded.
Pls help me regarding this.
thanks in advance.Hi
You can create it in both ways.if you create datastore by using ODI you must select create target table option in flow while loading to target.
Maybe you are looking for
-
IPrint app for iOS fails to print photos in colour
We are running the latest build of the iPrint Appliance (Version: 1.0.1.69 Patch 1) and cannot get the iPrint app for iOS to print photos in colour. I suspect that this is a problem with the internal renderer and JPG files. Printing a PDF, DOC or DOC
-
Can I get a copy of the os somewhere to put on a thumb drive to reinstall when I change the drive?
-
LSO -- where in configuration do you enter URL for portal / corses
LSO -- where in configuration do you enter URL for portal / corses
-
The Edit Reconciliation Policy action was not valid
I�m trying to �Edit Reconciliation Policy� in IDM 7.1 from Resources -> List Resources and the drop down menu �Resource Type Actions� but It is giving error message *�The 'Edit Reconciliation Policy' action was not valid for one or more of the select
-
"Partner Delivery Point Not Found" in SUS Purchase Order
Working on SRM5.0, I have created Purchase Orders in SRM which have been transmitted to SUS via XI. The PO's appear in SUS, but when I try to process the PO as the vendor (in order to send a PO response / goods confirmation etc back to SRM), the foll