This question already has answers here:
How to generate entire DDL of an Oracle schema (scriptable)?
(7 answers)
Closed 2 years ago.
I want to create tables from one schema to another. i.e. complete table script.
eg: Let say in schema 'A' tables are present and need to create in schema 'B'.
Can we do this with a scripts as there are lot of tables? or manually is the only option?
Could anyone pls suggests.
Thanks.
Yes it can be done by a script. Below, you will find the example of how to retrieve the DLL of a single Table. Now, using this example, you can create the script in no time.
SELECT DBMS_METADATA.get_ddl ('TABLE', table_name, owner)
FROM all_tables
WHERE owner = 'OWNER'
AND table_name = 'TABLE_NAME';
If you want the script directly, the following Link will provide you with your desired result:
How to generate entire DDL of an Oracle schema (scriptable)?
Related
This question already has answers here:
Bulk Insert of Generic List C# into SQL Server
(4 answers)
Closed 9 years ago.
Is there a fast, efficient way in VB.NET/ADO.NET to insert large amount of data from Geneneric.List(Of Integer) into SQL Server table besides looping thru the list and issuing individual INSERT commands? I am limited to .NET 3.5 and SQL Server 2005.
Thanks!
Ship XML with all the changes to a stored procedure.
Here is an old example here:
http://granadacoder.wordpress.com/2009/01/27/bulk-insert-example-using-an-idatareader-to-strong-dataset-to-sql-server-xml/
Here is a smaller example, but shows the basics.
http://www.mindfiresolutions.com/Sending-Multiple-Records-As-XML-To-SQL-Server-Stored-Procedure-1861.php
Send xml to stored procedure. Shred the xml to a #variable or #temp table. Do your UPDATES / INSERTS (or MERGE/UPSERT) using the #variable or #temp table.
http://weblogs.asp.net/dwahlin/archive/2009/09/30/passing-multiple-records-to-a-stored-procedure-in-sql-server.aspx
Another example.
What I like to do is create a strong dataset. Put your data into the strong dataset. Then send the ds.GetXml() to the stored procedure.
That way, you get strong typing (using the strong dataset), and you don't have to write your own xml-maker, you piggy back off of .GetXml(). Hint: After creating the strong dataset, remove the namespace (tempuri or something like that)
This question already has answers here:
Search for a string in all tables, rows and columns of a DB
(15 answers)
Closed 9 years ago.
I've been scouring online for an example of how to do this but haven't found anything at all. All the queries I've found assume you know what table you want to search.
I'm looking for a SQL query to simply search the ENTIRE database for a specific word.
There has to be such a thing right?
This is for MS SQL 2005/2008
Thanks
What do you mean by "entire database"? You need to find your values in tables only, or in object definitions, too?
I assume the former. In this case, you don't have to really know the structure of your DB. Try those views below. With them, you can construct your select queries on all the tables / colums. Just filter out non-*char columns, views and system tables, and you're ready to go - you can "automatically" generate multiple select statements.
select top 100 * from information_schema.tables
select top 100 * from information_schema.columns
The other option, is to use some addon to SSMS, like this one:
http://www.ssmstoolspack.com/
It has an option to search entire database.
But be advised, that both solutions will have a great impact on performance of your server.
This question already has answers here:
Find a value anywhere in a database
(18 answers)
Drop all the tables, stored procedures, triggers, constraints and all the dependencies in one sql statement
(21 answers)
Search all tables, all columns for a specific value SQL Server [duplicate]
(4 answers)
Closed 8 years ago.
My question might sound stupid, but does there exist a script that could find out where in database, for which tables, is the desired data located? Say for example, i need to found where Texas is located in database, in which tables and in which column.
There exists a script that could find out the tables, SP, views based on the column name provided. Is there any script that could find out tables, column name etc based on the actual data?
Hope the question is understood.
Best Regards
Josh Walker has a script that will find the number of incidences a string of text is found, and in which tables:
http://www.sqlservercentral.com/scripts/Miscellaneous/65769/
And, this statement should find any procedure code that contains the text you are looking for:
SELECT OBJECT_NAME(id)
FROM syscomments
WHERE [text] LIKE '%whatever%'
The SSMS Tools Pack gives you this kind of search functionality plus various other cool things for free. And no, I don't work for them!
I have got one great tool that can find data anywhere located in the database. It is known as SQL Locator. Just Google it, that should be easy to find. Plus it is a freeware to download.
Thanks!
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
i have an excel file which describe all the table structure of a database table
I would like to generate database schema diagram and database schema structure for sqlite3 database from this excel file.
Any idea how to do that ?
Thanks.
Assuming each tab is named for a table and has cells as such:
Name DataType
ID integer
Name varchar(255)
Use either Python or Java to read the workbook using python-excel or Apache POI for Excel, respectively. I'm sure other languages, particularly .NET have libraries for this purpose as well. Both languages also have drivers for sqlite3.
Iterate through each tab - use the tab name for the table CREATE statement. Iterate through each row on the tab and use that information to define the columns for the table. Defining things like primary/foreign keys and auto incrementing will require some additional cells or a naming convention + some clever algorithms.
Most likely each CREATE statement will need to passed separately over the database connection.
There are usually better tools to do this than Excel. Start with your SQLite3 database and analyse it with a db manager that has a schema editor like WinSQL.
Assuming that Excel contains fieldname and type columns
I would write tiny VB script which will translate those pairs into Java SQL strings like:
private static final String DATA_CREATE="create table if not exists\n"
+ "MYTABLE\n"
+ "DATA_ID integer primary key autoincrement,\n"
+ "RAW_ID integer not null,\n"
+ "ORDER_ID integer not null,\n"
+ "CHUNK blob);";
then just add this-alike strings into your Java source. Or as option you could SQL scripts write into file place them somewhere in assets on run them from SQLite
If I were to write such a program I would make the following assumptions:
The sheet would become the table name.
The column headers would become the column name.
The formatting rule of the column would control the data type.
With these constraints in mind, you could create an import and create tool.
To do this in Java, I would use a library that can read excel
files, for instance Apache POI:
(Here is the maven dependncy I use for it)
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.6</version>
</dependency>
Read the excel file using POI, analyze the columns and
dynamically create the table in the sqllite database. (drop the
table if it exists). Then based on the type generate a prepared
statement and insert the data based on each of the rows in the sheet.
This would be the basic setup. From there you must decide how
to do foregin keys if you need it and so on.
I don't think that what you requesting is possible.
A solution for your question, will be to post an example table from excel, and request help to transform it into SQL
This question was migrated 12 years ago.
I need to take back up of MySQL database,but condition is that back up file should contains only tables that contains data, and there should be an create and drop statements too.
I checked mysqldump manual pages, didn't get options.
If you know the tables that contain data, why do you not simply selectively dump those tables?
mysqldump [options] [db_name [tbl_name ...]]