generate database & tables schema (ddl) on Oracle pl-sql - sql

Anyone have a PL-SQL statement that i can use to generate database & tables schema for specific database on Oracle 10g? I need the schema in .sql file and if possible compatible with ANSI-92/99 sql implementation, so i can use the generated .sql directly on sql server 2005.
Already heard about exp/imp, but it seems generated dump file, what i need just a simple ddl on .sql file.
Thanks

You could try:
select dbms_metadata.get_ddl('TABLE',table_name,owner)
from dba_tables where owner='schema name';
It returns longs, so you may want to play with the long buffer.
More about dbms_metadata here: http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_metada.htm

If you just need to dump your schema, this free package does a very nice job. We use it in daily production.
http://sourceforge.net/projects/cx-oracletools
If you need to convert from Oracle to SQL Server, this software might do a better job. We've used it to convert between Oracle, MySql, and Postgreqsql.
http://www.spectralcore.com/fullconvert

I wrote oraddlscript which calls dbms_metadata.get_ddl (Pop's answer) for each database object owned by a user and writes the DDL to a file.
Update: Answered comment

Greetings, I'd recomend using Oracle SQL Developer Data Modeler since it's from Oracle, it can read the DDL information directly from the Data Dictionary. It creates an ERD and then you can produce DDL for SQL Server 2000/2005, some versions of DB2 and Oracle 9i/10g/11g.

Related

Generate DDL script for MySQL in Oracle SQL Developer

I made a relational model in Oracle SQL Developer and I want to make tables in MySQL Workbench. I generated the DDL script in SQL Developer and copied it in MySQL Workbench. I found out that the copied queries are not in correct syntax. I tried different options in SQL Developer to generate script and none of them were in MySQL syntax.
Is there a way to generate DDL script from a model, which is made in SQL Developer, for MySQL?
There is no straight query generation for MySQL in oracle SQL developer. You should use such a sites for your purpose to convert them into MySQL syntax or use tools for automatic converting.

Optimal way to Load Data from SQL Server to DB2

We have 40+ Tables present in SQL SERVER DB and we need to copy the data to an IBM DB2 database. What methods do you recommend to accomplish this?
My ANALYSIS:
BCP and Data Import - The team is trying to avoid any BCP files
Write Stored procedure and use LINKED Server in SQL and insert the data in DB2
SSIS Packages to move data.
Please let us know if you have any better way to approach this issue.
Have you considered Information Integration, that is known in DB2 as federation? you can do a select in SQL Server directly from DB2, and with this feature you can define a cursor and then just use the LOAD command.

is there a tool to dump a database schema (SQL DDL) to XML?

I'm looking to automatically generate an XML version of a database schema from SQL (Postgres) DDL.
Are there any tools to help with getting from the DDL to XML?
xml2ddl claims to do this, but it fails to connect and seems unsupported since 2005.
You can use the built-in table_to_xmlschema etc.; see http://www.postgresql.org/docs/current/static/functions-xml.html#FUNCTIONS-XML-MAPPING.
Things that spring immediately to my mind:
Liquibase
Schemaspy
SQL Workbench's WbSchemaReport
They don't use a DDL (SQL) script as input but require a database connection.
Have you also researched DbUnit?

How can I import a database schema into MS Access 2003 from sql text file?

I have a database schema generated in a text file (DDL - MS Access compliant).
Where is the option in MS Access to import that schema into an empty database ?
I'm not aware of any import for DDL.
However, DDL contains the definition for the schema.
You simply have the execute DDL as you would any query.
Either create a query, put it in sql mode, paste your ddl, and execute
or....
Create a VBA Sub to essentially do the same: currentdb.execute SQL
Good Luck
To execute a SQL DDL in the SQL View of a Query object, you may need to change the Access user interface to ANSI-92 Query Mode. While the 'traditional' query mode (ANSI-89 Query Mode) supports a SQL DDL syntax it is very limited.
The Access database engine can only execute one SQL statement (DML, DDL or DCL) at a time. To execute a SQL script consisting of multiple SQL statement, you need something to parse individual SQL statements, so it really helps if your script has semicolon ; characters separating them, then execute each statement on at a time i.e. synchronously. If you are doing this in VBA code you are better off using ADO because it always uses ANSI-92 Query Mode.
See if this helps: http://support.microsoft.com/kb/180841
I have been very succesful with reverse / forward engineering MS Access databases with Dezign for Databases by Datanamic. It reads all kinds of DDL scripts (from almost all available database) and can translate between different databases. There is a free trial available.

CREATE TABLE reverse engineering in Oracle

In Oracle SQL Developer, there's a "SQL" tab for each table. This tab contains most of the SQL code (CREATE TABLE, CREATE TRIGGER, etc) that's needed to recreate the table.
Is this information available programatically from the database system, or is this an application feature of SQL Developer? If the former, what commands/statements would I need to run to retrieve this information? If the later, are there any clever ways to get SQL Developer to export these statements?
If you are using Oracle 9i+ then you are looking for the DBMS_METADATA package. http://download.oracle.com/docs/cd/B10500_01/appdev.920/a96612/d_metada.htm. It will allow you to extract whatever DDL you want.
If you are looking for more specific information there is a whole host of views you can access for specific data elements similar to the ones given by #Quassnoi.
There are lots of information, but here are the main queries:
SELECT *
FROM dba_tables
SELECT *
FROM dba_tab_columns
SELECT *
FROM dba_ind_columns
To see what SQL Developer actually outputs, enable trace for all sessions with a LOGON TRIGGER and look into the trace file created by SQL Developer's internal session.
You are looking for the DDL of your database objects.
You can use the Oracle bundled DBMS_METADATA package to get it, from any PL/SQL prompt, with the GET_DDL function.
I use TOAD vs Oracle SQL Developer.
When I click on a "Script" tab when viewing an object (like a table) TOAD executes a whole host of queries and then compiles the "script" from the output of all of these queries.
dba_tables
dba_tab_columns
dba_ind_columns
...
I think replicating this functionality would be a tedious task.