I have some tables with huge columns (more than 600 columns) and don't have DDL(create table) scripts for it. I can create the script by seeing the table schema using DESCRIBE keyword in oracle nosql, but it's a huge pain in the back because of manual operation.
Is there any way to generate DDL scripts for existing tables in Oracle NoSql database?
There is no way to do this at this time. It's being considered as an extension to the sql shell. One option in user code would be to use the "describe as json ..." call and parse the JSON description of the table to construct the DDL string
Related
The goal is to export an existing test Oracle database to SQL so that it can be run in a test pipeline using a Docker images's /container-entrypoint-initdb.d bootstrap. Currently we mount an oradata export, but it's opaque what the actual data is, hence the desire to use SQL so that it can be maintained via git.
I'm aware you can use the GUI Oracle SQL Developer Export Wizard to export a database to SQL.
Though how to do it via command line tools? I've tried many things like:
impdp test/test#XEPDB1 dumpfile=export.dmp directory=DUMP_DIR sqlfile=ddl.sql
And the best I can achieve is exporting the schema, however it is missing the actual data, e.g.
INSERT INTO currencies_countries (currency_id, country_id) VALUES ('EUR', 'CYP');
You have the exp which exports to a dump file that can be imported into another Oracle DB using imp. More recent are the xpdp and impdp.
See: https://oracle-base.com/articles/10g/oracle-data-pump-10g for instance.
What do you mean by "export to SQL"?
The sqldeveloper client tool has the possibility of exporting a table as SQL inserts, for instance. But to export that table by table would be quite an effort. Moreover, if you have millions of rows, those row by row inserts won't perform well.
Better write to tab-separated text files, which, in case of need may be imported into an Oracle DB using sqlldr, or may somehow be imported to some other kind database. Still, tab-separated files won't work well for tables having CLOB, XMLTYPE or some object-type columns.
You could write to a text file by spooling sqlplus output to a file having set linesize ling enough to fit the columns length, set pagesize 0 (no pages).
Or you could write to a file in an Oracle directory via a pl/sql program in which you use utl_file.
I need to export data from one schema and import it to another. But in the second schema there are tables with different names, different attribute names, etc, but these tables are suitable for data in first schema. So I export data as SQL inserts and manually rewrite names etc. in this inserts.
My problem is with tables which have columns with type BLOB. PL/SQL Developer throws error:
Table MySchema.ENT_NOTIFICATIONS contains one or more BLOB columns.
Cannot export in SQL format, use PL/SQL Developer format instead.
But, when I use PL/SQL Developer format (.pde) it is some kind of raw byte data and I can't change what I need.
Is there any solution to manage this?
Note: I use PL/SQL Developer 10.0.5.1710 and Oracle database 12c
i am working on a large database ,how do i Export some database tables without having dba privileges .do i have to copy the structures of the tables and using spool command to get the data in a text file then create the tables and inserting data from the text file?
One of the methods would be to install Oracle SQL Developer and export the required table structures and data using the wizard.
Here is the link to a tutorial which can guide you if you go with this option.
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/sqldev/r30/SQLdev3.0_Import_Export/sqldev3.0_import_export.htm
A second option would be to use SQL Loader to load data in your target tables. But for that you will have to first create the data structures on your target schema and spool the data from your source tables in CSV (comma separated values) or any other eligible format.
Here is a link for SQL Loader.
http://docs.oracle.com/cd/B28359_01/server.111/b28319/ldr_concepts.htm
A third option would be that you create the table structures on the target schema and generate the insert statements from the source schema using a script. Here is a link to such an example.
https://pandazen.wordpress.com/2008/08/18/generate-insert-statement-script-to-extract-data-from-oracle-table/
I would recommend going with the SQL Developer option since it is relatively simple.
I've created a relational model in Oracle SQL Developer Data Modeler.
I want to add predefined\static data that should exist in the initial clean database: enum values, fixed lists( for example: contries ) using modeler. My goal is to receive script using "DDL File Editor" tool which contains not only "create table" commands and so on, but also "inserts" with initial data.
I there any way to do this?
What might be the easiest way would be to put the DML into the AFTER CREATE tab under Scripts for each table - and to make sure it's included in the DDL script.
I am needing to export the tables for a given schema, into DDL scripts and Insert statements - and have it scripted such that, the order of dependencies/constraints is maintained.
I came across this article suggesting how to archive the database with data - http://www.dba-oracle.com/t_archiving_data_in_file_structures.htm - not sure if the article is applicable for oracle 10g/11g.
I have seen "export table with data" features in "Sql Developer", "Toad for Oracle", "DreamCoder for Oracle" etc, but i would need to do this one table at a time, and will still need to figure out the right order of script execution manually.
Are there any tools/scripts that can utilize oracle metadata and generate DDL script with data?
Note that some of the tables have CLOB datatype columns - so the tool/script would need to be able to handle these columns.
P.S. I am needing something similar to the "Generate Scripts" feature in SQL Server 2008, where one can specify "script data" option and get back a self-sufficient script with DDL and data, generated in the order of table constraints. Please see: http://www.kodyaz.com/articles/sql-server-script-data-with-generate-script-wizard.aspx
Thanks for your help!
Firstly, recognise that this isn't necessarily possible. A view can use a function in a package that also selects from the view. Another issue is that you might need to load data into tables and then apply constraints, even though this might be slower than the other way round.
In short, you will need to do some work here.
Work out the dependencies in your system. ALL_DEPENDENCIES is the primary mechanism.
Then use DBMS_METADATA.GET_DDL to extract the DDL statements. For small data volumes, I'd extract the constraints separately for applying after the data load.
In current versions you can create external tables to unload data from regular tables into OS files (and obviously go the other way round). But if you've got exotic datatypes (BLOB, RAW, XMLTYPEs, User Defined Types....) it will be more challenging.
I suggest that you use Oracle standard export and import (exp/imp) here, is there a reason why you won't consider it? Note in addition you can use the "indexfile" option on the import to output the SQL statements (unfortunately this doesn't include the inserts) to a file instead of actually executing them.