creating a table from a select statement
is it possible to run a select statement that creates a table based on the statement of execution? in MSSQL I can include 'in {tablename}"in a select statement and it will automatically create the table field names / on the fly?I know I can run "insertion in {tablename} select * from foo" to fill an existing table, but I want something that creates the table as well.
create table
as select ...
Is that what you are looking for?
Nicolas.
Tags: Database
Similar Questions
-
Creating a table using the Select statement of the physical layer
Hello
I use 10G, and I have the sub query in my physical layer. I chose the type of Table as Select and gave the SQL below. When I say the number of lines of update updates lines 93, that is correct, but does not show me the columns, or when I say display data, it does not show me the data, please see if I'm doing something worng. Thanks for your time and your help.
Select (select program_id, project, actvty_id, commitment_date, row_number() over (partition by order project by commitment_date desc) as rnk project, actvty_id, program_id, commitment_date)
of project_detail) a
where rnk = 1Yes, create columns individually and click view data, you'll be able to get data
-
Create table in the select statement.
Hello Oracle gurus,
I am creating a table using select * in the other table.
The procedure I am following is as follows: -.
I have a temporary table whose signature is on delete rows commit.
I insert records into this table.
When I select * from temporary_table, perm_table, I get a few lines.
so I try to create a result_table the use of this
CREATE TABLE result_table
AS SELECT * FROM temporary_table, perm_table;
I see the created array, but the number of records in 0. Please can someone explain where the validation is performed while the sequence in this query occurs.
Thank you
Published by: user10696492 on November 10, 2009 08:47Hello
When you perform DDL like CREATE TABLE implicit validation takes place just before and just after the statement.
Concerning
Peter -
normalize the schema of the table in a select statement (without view)
Hello
I have a table storing a physical value, mean temperature for different locations every minute. The table schema is as following: timestamp (datetime), rental (string), value (number).
Do you know a way to have a select statement, return of lines with the following data: timestamp, the value at location1, value of place.2 guests, etc.
This will help me to create time series in he same diagram in my reporting tool.
This may be possible with a view, but I don't have access to the database, the best I can do is set my a data source such as a select statement.
Thank you!
Brahim
PS. We use Oracle 10 g R2
Hello
8e07ad81-CDAE-4c23-b0fb-b6cd117cf5bc wrote:
Hello
I have a table storing a physical value, mean temperature for different locations every minute. The table schema is as following: timestamp (datetime), rental (string), value (number).
Do you know a way to have a select statement, return of lines with the following data: timestamp, the value at location1, value of place.2 guests, etc.
This will help me to create time series in he same diagram in my reporting tool.
This may be possible with a view, but I don't have access to the database, the best I can do is set my a data source such as a select statement.
Thank you!
Brahim
PS. We use Oracle 10 g R2
What you're asking about is called pivoting. The ahs Forum FAQ page devoted to this topic: Re: 4. How can I convert rows to columns?
Since you're using Oracle 10, you cannot use the SELECT... Function PIVOT; You can use GROUP BY and CASE instead.
Do ' t worry not about creating views. What you can do with views, you can also do it using a WITH clause in your query.
If you get stuck, please post some sample data (CREATE TABLE and only relevant columns, INSERT statements) for all of the tables involved and also to publish the results you want from this data, as well as your best attempt to query a specific question.
Explain, using specific examples, how you get the results desired from data provided.
See the FAQ forum: Re: 2. How can I ask a question on the forums?
-
TimesTen create a lock for a select statement through sqldev
What ttisql use connect to TimesTen Release 7.0.6.15.0 to autocommit = 1, there is no lock for a select statement.
but when I use sql developer (driver is ttjdbc5.jar, regardless of the version) to connect, even with autocommit = 1, there will be locks for the select statement.
Is this a bug? How can I achieve the same no lock for a select statement through sql developer? Thank you.
-your update told me that you are connected to a remote timesten data store using the client driver
-the output from ttXactAdmin shows that SqlNavigator has a shared lock on the database itself: it will not interfere with someone else "read operations and I think that until you actually try a kind of DML against the database that e IX lock on the database lock will not interfere with any other DML either."
-sharing database lock is still acquired for any transaction TimesTen. You can test it for yourself ttisql: set off autocommit, perform a simple update and do not commit the transaction. Then, open a separate session and run ttxactadmin - you will have the database IX lock as well as the various locks on the tables and indexes.
-I think this pretty much proves my original thought: this sqlDeveloper attaches to TimesTen in transaction mode. However, the IX lock on the database will not interfere with anyone else's work and should not be a problem.
-
Is it possible to use the record type or a PL/SQL table in the Select statement
Hi all
My requirement is that.
I want to write a query and write a function, function, I want to return multiple columns at the same time in a Select statement.
I select the return values in the Select no statement in a PL/SQL block.
Is it possible to use the PL/SQL Table or Variable of Type record, or any other method in the statement Select?
Please help me understand the solution.
Kind regards830960 wrote:
do we like it?In general, Yes, if the function is a function table, you can do something like:
select t.col1, t.col2, f.col1, f.col2, f.col3 from table_name t, table(some_table_function(param1,...paramN)) f /
SY.
-
create view force executes a select statement
I have the following script, which is called during the installation as a user the_owner with @Code\Views\VW_TODO. from sqlplus
I get the following output in my journal...Prompt View VW_TODO; CREATE OR REPLACE FORCE VIEW the_owner.VW_TODO (THE_ID, COUNT) AS --+============================================================================ -- Project Code: -- Project Name: -- Module Type: View -- Change History: -- -- Name Version Date Comment -- -- ============================================================================= SELECT the_id, COUNT ( * ) COUNT FROM the_owner.todo_list WHERE completed IS NULL GROUP BY the_id; /
I have tried with and without the trailing slash and the final semicolon... no work...View VW_TODO no rows selected no rows selected
When I run SQL Developer, it creates the view.
Can someone tell me why?
Thanks in advance,
Gus...Gus,
It seems that you have a completely empty line in your CREATE VIEW statement. This will cause the statement fails. If please remove this line and try again.
Andy
-
How to create a sequence within a select statement
I have the following query
He will return for exampleselect t.id_trato2 as DEAL_ID, -- 1 as SEQ_NO from treats t order by id_trato2, seq_no
id_trato2 seq_no
1 s
1 s
4 1
4 1
4 1
I need to return
id_trato2 seq_no
1 s
3 2
4 1
1 W
4 3
Can how I do this?Try this:
select t.id_trato2 as DEAL_ID, row_number() over (partition by t.id_trato2 order by t.id_trato2) as SEQ_NO from treats t order by 1, 2
Published by: kendenny on November 23, 2010 11:40
-
Creating a table visual materials with State
Hello
I'm new to advanced in Captivate actions (I have installed 5 soon a Mac update and willl to 5.5).
I need to create a visual content/menu that changes after the learner has completed the section they have seen. In other words a small badge or check mark is added to the Visual button.
Map of base here:
http://magdadiaz.com/InteractionMap1.PNG
I know how to do this in Flash but my client wants to Captivate.
Can somone point me to a good tutorial on how to do this?
It sounds simple enough, but I can't find a good tutorial.
Thank you.
Maybe take a look at this blog post and the model:
Lilybiri
-
Add a new column in a CREATE - AS SELECT statement
I create a table using a select in an existing table. I would also like to add a new column (with nulls for all records). Is this possible? What is the syntax for this column?
Thank you
Kevinuser10856100 wrote:
I create a table using a select in an existing table. I would also like to add a new column (with nulls for all records). Is this possible? What is the syntax for this column?Thank you
KevinKevin,
In any case, create table will not accept one byte NULL for the column declaration.SQL> create table e(empno,ename, sal, new_co) as select empno,ename, sal, to_number(null) from emp; create table e(empno,ename, sal, new_co) as select empno,ename, sal, to_number(null) from emp * ERROR at line 1: ORA-01723: zero-length columns are not allowed SQL> create table e(empno,ename, sal, new_co) as select empno,ename, sal, to_number('12') from emp; Table created. SQL> desc e Name Null? Type ----------------------------------------- -------- ---------------------------- EMPNO NUMBER(4) ENAME VARCHAR2(10) SAL NUMBER(7,2) NEW_CO NUMBER SQL> select * from e; EMPNO ENAME SAL NEW_CO ---------- ---------- ---------- ---------- 7369 SMITH 0 12 7499 ALLEN 0 12 7521 WARD 0 12 7566 JONES 0 12 7654 MARTIN 0 12 7698 BLAKE 0 12 7782 CLARK 0 12 7788 SCOTT 0 12 7839 KING 0 12 7844 TURNER 0 12 7876 ADAMS 0 12 EMPNO ENAME SAL NEW_CO ---------- ---------- ---------- ---------- 7900 JAMES 0 12 7902 FORD 0 12 7934 MILLER 0 12 7369 SMITH 0 12 7499 ALLEN 0 12 16 rows selected.
HTH
Aman... -
Create a new table from another table which are ussing a stored procedure
Hello
I want to know if it is posibble to create a new table from another table which are ussing a stored procedure. This new table is created from another table that exists in the DB.
(in the following code the table tbl1 exist in the schema of the DB, but temp_tbl1 does not exist, it must be created by the procedure)
create or replace procedute temp is
temp_tbl1 tbl1% TYPE; the temp_tbl1 will have the same type of tbl1
Start
create the table temp_tbl1 as (select * from tbl1);
time of the end;
\
Thank you very much
Yes, it is possible to create a table using a procedure.
Do everything that use dynamic SQL isTry this:
==================================================
create or replace PROCEDURE Create Table as
BEGIN
EXECUTE IMMEDIATE ' CREATE TABLE testtable in select * from testingtable';
END createtable;
==================================================Kind regards
Ankur -
I have a table repair with 500 repairs (range) on 10.2.0.4 db
I created a table in db 11 g 2 using db link
create the table temp_order_hist in select * from order_hist@10db;
When I do its partations not create
is there way I can do create table and get the partations
Thank youis there way I can do create table and get the partations
Yes,
CREATE TABLE my_objects PARTITION BY RANGE (created) (PARTITION part_old VALUES LESS THAN (TO_DATE ( '201001', 'yyyymm')), PARTITION part_other VALUES LESS THAN (maxvalue) ) AS SELECT * FROM user_objects;
Concerning
Peter -
can I get an exact part of the data in a select statement
Hi... good afternoon...
I want to extract the records from a table by the select statement. but I don't want to go as it's the folder. I want to go look for a particular part of the eacg folder in this column.
for example...
table_name = tab1
column_name = col1
the col1 contains datas as * 'customer research-cs', 'get client-gc', 'customer delete-cd' * etc etc...
now, while writing the select query, I want to get the descriptive result as get the customer, customer, customer search remove... .that is I don't want the symbols...
is it possible to achieve this?
PLSS suggest...You mean like these ways to do...
SQL> ed Wrote file afiedt.buf 1* select substr('customer search-cs',1,length('customer search-cs')-3) from dual SQL> / SUBSTR('CUSTOME --------------- customer search SQL> ed Wrote file afiedt.buf 1* select regexp_substr('customer search-cs','^[^-]*') from dual SQL> / REGEXP_SUBSTR(' --------------- customer search SQL>
-
SQL SELECT statement as a parameter in the procedure of string
Hi all
I'm new to PL/SQL and I must get a procedure as parameter select SQL select statement as a VARCHAR and the production output the result of the statement with a few changes. Can someone help me solve this problem?
A possibility I thought at was to use a REF CURSOR. The following example works but binds me to a specific table (in the example of the "customers" table). However, I need the ability to specify arbitrary tables in the select statement parameter.
My idea was to modify this example to work in the following code, but it does not work (I get a compile error):SET SERVEROUTPUT ON DECLARE TYPE my_cur IS REF CURSOR; query_cursor my_cur; BEGIN OPEN query_cursor FOR 'SELECT * FROM customers'; DECLARE record_type customers%ROWTYPE; BEGIN LOOP FETCH query_cursor INTO record_type; EXIT WHEN query_cursor%NOTFOUND; DBMS_OUTPUT.PUT_LINE('some output ... '); END LOOP; END; CLOSE query_cursor; END; /
Does anyone has an idea how can I solve my problem?SET SERVEROUTPUT ON DECLARE TYPE my_cur IS REF CURSOR; query_cursor my_cur; BEGIN OPEN query_cursor FOR 'SELECT * FROM customers'; DECLARE record_type query_cursor%ROWTYPE; BEGIN LOOP FETCH query_cursor INTO record_type; EXIT WHEN query_cursor%NOTFOUND; DBMS_OUTPUT.PUT_LINE('some output ... '); END LOOP; END; CLOSE query_cursor; END; /
Thank you very much!
(I'm using Oracle 11 g)This can help.
Re: Dynamic Extraction on dynamic Sql -
Creating the table with time stamp
I need to create the table with the data inside buffer
Can you help me pls
If it works today,
create the table test_04NOV2010 in select * from product where product_code = '101'
If executed tmrw,
create the table test_05NOV2010 in select * from product where product_code = '101'
can is it you pls let me know how to use it in PL SQLdeclare v_date varchar2(25); v_sql varchar2(20); begin select to_char(sysdate,'DDMONYYYY') into v_date from dual; v_sql := ' create table ' ||TEST||'_'||'v_date'|| ' as ' ' select * from Product where product_code = '101' EXECUTE IMMEDIATE v_sql; end;
Can you help me pls
Thank you very muchdeclare v_date varchar2(25); v_sql varchar2(2000); --Noted this. this was also small. begin select to_char(sysdate,'DDMONYYYY') into v_date from dual; v_sql := ' create table TEST_'||v_date|| ' as select * from Product where product_code = ''101'''; EXECUTE IMMEDIATE v_sql; end;
You can use the Q operator also.
DECLARE v_date varchar2(25); v_sql varchar2(2000); BEGIN select to_char(sysdate,'DDMONYYYY') into v_date from dual; v_sql := ' create table TEST_'||v_date|| Q'[ as select * from Product where product_code = '101']'; EXECUTE IMMEDIATE v_sql; END;
Published by: mohamed on November 4, 2010 05:32
Maybe you are looking for
-
where can I get the Shockwave Flash plug-in
Shockwave Flash caused my browser 40.0.3 to launch the videos, I didn't play, I added an add-on to block the Flash Shockwave; However, this has become very cumbersome to turn on and off when I go to sites requiring Flash as a greeting card site. I fo
-
Settings of records that overlap do not work
When I call my settings of the duplication of records, they are all "replace". I choose another option in the menus, but they do not. I can not any setting other than "replace". This is true for MIDI and Audio settings. Everything else in the dialog
-
How to keep a bet in the form of Sources while sticking in the Pages
In the Bible, the personal name of God is replaced by the title of 'Lord' by using small capitals. When the copy of the Bible and paste into the Pages, the title of 'Lord' pasta without small capitals. However, when you paste in my email client, the
-
Upgrade Touchsmart 600 for 3 to 4
I lost my files and the link to the forum their going to a "not found". I am running Windows7 64 bit. Where can I download them?
-
Multicolum money Lisbox Scrollbar
Good afternoon. Can be configured with a Silver Scroolbar of Listbox separate multicolumn IndexVals witch? (Untitled 1(vi)). I want to have a scroll bar can be placed in the table. (Untitled 2.vi). Thank you very much.