I want to generate an insert script for a table. I don't know how to generate it from the table structure with SQuirreL as I do it with pgAdmin.
With pdAdmin I do this:
Getting this result:
I have tables with a lot of columns(60) and I really don't want to write the script.
Hope exist a similiar option with SQuirreL
Not exactly the same but, you can right click over a row of data and select 'Copy as SQL INSERT-VALUES statement'.
Related
Our schema was built by my predecessor with most column names and some table names having "" around them. I suppose it was an artifact of an import process. I rename the columns when I'm working on parts of the database, and plan to rename all the rest eventually. Meanwhile, I can see the column names in Toad, on the Script tab, where I can see the CREATE TABLE... code. But I don't see them when using a simple DESC command in SQL Plus. Is there a way to show the double-quotes around the column names and some table names in SQL Plus?
It matters because my colleague is old-school and doesn't have access to Toad. I had access to Toad, but lost it a while back and don't know when I will have it again. There's bureaucracy in the way. But that's another story. Thank you.
I'm trying to figure out in which of the many parquet files is the data stored in table for a particular set of date condition.
For example:
select filenames from table where dateCol = '1-1-2010';
I remember this reading somewhere that it's possible but couldn't recollect anything as such; neither could I find it elsewhere. Anybody got any ideas?
Got it.
select distinct(INPUT__FILE__NAME) from table where conditions;
I need sone help in PL/SQl.
So my problem is, the following problem:
There is a table called: temp_table and I need to create a temp_table without drop/truncate option. It needs because all the time a table's data changing.
So I know its weird, but this is necessary for my daily job.
The script work like this:
The script does a text import to table, and the table is given. It use a dblink to connect the database. It works, but all the time I have to use DROP. But I need ( if its possible) to create an existing table without drop/truncate.
Can someone help me?
Thanks a lot.
Sorry for no sql code, but i think it doesn't necessary.
I think the concept you want is the external table. With external tables the data resides in OS files, such as CSVs. This allows us to swap data sets without dropping the table.
Find out more.
I take it you want to drop the table because you want to reload it, but you also want there to be as close to constant up-time as possible?
I would create two temp tables. You already have one called:
temp_table
Create another called:
temp_table_new
Load your new data into temp_table_new, then run a rename on it like so:
RENAME TABLE temp_table TO temp_table_old
temp_table_new TO temp_table
Then
drop table temp_table_old
This will be super fast, have very little downtime, and allow you to have the functionality you've described.
I have a task to compare some Teradata Views with actual Oracle Tables.
I need a script for that.I have taken Java approach in which I connect to a specific schema from Oracle and then call the SELECT * FROM all_tables order by TABLE_NAME query and write this into a file.
I do the same for other schema but now my problem is Teradata.
Can you people please suggest me some script or query by which I can get proper details like it does with Oracle.
There is no complex Java Code but if you still want I can post it.
Edited:
Okay now I have a schema in Oracle which has all the tables.so views for those tables are created in Teredata.
I have to compare oracle tables and Teradata views every morning and send the differances.
So I use SELECT * FROM all_tables order by TABLE_NAME in Oracle and for Teradata I use SELECT * FROM dbc.tables WHERE tablekind='V' AND databasename='SCHEMA' order by TableName so now when I compare them I dont get accurate results, so I wanted to know does any script exists or how do I approach.
If your question is "How can I programmatically determine the structure of a view in Teradata?", then this should be a step in the right direction: HELP VIEW yourviewname;.
To get a list of views on a given table:
SELECT TableName
FROM DBC.Tables
WHERE Tablekind = 'V'
AND requestText LIKE '%yourtablename%'
GROUP BY 1
ORDER BY 1;
This information was gleaned from the official Teradata forums. You might also be interested in the Teradata users manuals. (Select your release version on the top right.)
I want to create a table (lets say table_copy) which has same columns as other table (lets call it table_original) in Oracle database, so the query will be like this :
create table table_copy as (select * from table_original where 1=0);
This will create a table, but the constraints of table_original are not copied to table_copy, so what should be done in this case?
Only NOT NULL constraints are copied using Create Table As Syntax (CTAS). Others should be created manually.
You might however query data dictionary view to see the definitions of constraints and implement them on your new table using PL/SQL.
The other tool that might be helpful is Oracle Data Pump. You could import the table using REMAP_TABLE option specifying the name for the new table.
Use a database tool to extract the DDL needed for the constraints (SQL Developer does the job). Edit the resulting script to match the name of the new class.
Execute the script.
If you need to do this programmatically you can use a statement like this:
DBMS_METADATA.GET_DDL('TABLE','PERSON') from DUAL;