generate sql script from tables - squirrel-sql

alt text http://www.freeimagehosting.net/uploads/64fac9c8c4.gif
is it possible to generate sql scripts from for all tables ? i want to generate the sql script and import into another database server

Select the tables you want to export, right click, scripts>create table script. It works in mysql, not sure about oracle.

For anyone on the 3.4.0 version on OSX, I had to do it this way:
Select the DB
Session >> SQL Server >> Generate T-SQL Script
Select the Objects/Tables wanted
Saves to a file, but gives you no progress indicator, so give it a while to run.

Related

Import MySQL file into Oracle SQL Developer

I have tried to find an answer for this elsewhere but cannot, I hope someone can help me.
I am trying to import the MySQL sample database into Oracle SQL Developer.
I have an existing database/connection I want to dump it into. I have created an empty table named classicmodels in my existing connection. Yes that name is only 1 table within the sample db, correct. Ignore the error in naming convention.
When I R-click on it and try 'import data' I cannot import a .sql file, I can only do it with XL, CSV, etc.
When I try and run a script it found on dba.stackexchange
#\path\mysqlsampledatabase.sql , I get a series of 'please provide substitution value' messages, which does not make sense to me given that I am importing a database which is built for SQL (ie what reason is there to substitute).
Pictures below:
The 'UnseenCollection' is a single table I imported as a csv file. I need to import the mysqlsampledatabase file such that it shows up the same way, I can access all tables within the sample db.
Anyone can help I would appreciate it. I need the end result to be the entire mysqlsampledatabase to populate within the 'classicmodels' node.
Thank you.
connect to MySQL
connect to Oracle
for a single MySQL table, right-click, 'Copy to Oracle'
for a few tables, select, drag and drop onto Oracle connection (requires newer version of SQL Developer)
for an entire MySQL database, use the migration project feature

Best way to synchronise data: MySQL -> SQL Server

I have a fairly straight way to copy selective data using SQL like so:
# Courses
DROP TABLE db_node.courses;
CREATE TABLE db_node.courses LIKE db_prod.course_sis;
INSERT INTO db_node.courses SELECT
*
FROM
db_prod.course_sis
WHERE
db_prod.course_sis.enabled = 1
AND db_prod.course_sis.hidden <> 1;
This is easy when I am on the same server with the same db, however I want to run this SQL to get put the final data on the SQL Server.
This isn't just a once off thing, it would need to be handled every hour or so. I am unable to change db's, one will always be MySQL and SQL Server because the data is used in a sharepoint app.
Thanks
There are several third-party tools to make this transition easier.
Check out SSMA here and here.
I'd also look at SQL Studio scheduled tasks to automate the process.

Need to update Mysql periodically from Oracle

I have a user table in Mysql. And this table is copied from another DB(Oracle).
Of course they have totally same table. And it needs to be updated once a day.(Mysql ← Oracle)
Is it possible to access Oracle and retrieve data within MYsql? I mean things like procedure.
(It seems possible between Mysql)
Or do I have to find other way?
Try to use Data Import tool in dbForge Studio for MySQL.
Start Data Import
Check ODBC format, specify its options and select table to import from
Specify mapping and other options
Select Append, Update or Append/Update import mode.
Also, you can run this tool in command line mode. Save data import template file and run it in command line mode once a day.

MySQL Workbench Inserts

I am using MySQL Workbench 5.2.28 for designing my database schema. I need to insert default data into some tables which can be done using the "Inserts" tab. However, it seems like it only allows entering data manually, one row at a time. I have an OUTFILE with several hundred rows that I would like to insert.
Is this possible with MySQL Workbench? Would creating separate MySQL scripts for importing default data be a better approach?
I am now using separate sql scripts for inserting my data as there doesn't seem to be an easy way to add bulk inserts to MySQL workbench.
Generate CSV (quoted if you have comas in values) in Excel for example, then just copy/paste all rows into workbench via 'inserts' tab for each table in model.
Works with Workbench version 5.2.40.
In the MySQL Workbench Version 6.2 you will find a Import Button which alows you to Import Inserts from a CSV File with "," as delemiter.
You are right there is no way I know doing this automatically. The only thing you can do is to generate all your inserts scripts in a single time by doing a forward engeniering and then by copying the insert statements at the end of the generated script (You must check the option "Generate INSERT statements").

How to generate SQL queries

I am using phpMyAdmin to create database tables and fields. I have 100's of tables in a single database. Now I need to make the same on few more servers.
I feel it's too hard to write SQL queries to create that database. Is there any reverse process to generate an SQL query file from phpMyAdmin or anyother tool? I want to create a database in a GUI, and I need the SQL query for my database. Is there any tool to generate it automatically?
If I understood you correctly, you want to export a database (with many tables) using phpMyAdmin, and then import it and use it on another server.
Yes. You can do that.
Select the database on the left-hand side in phpMyAdmin and then:
Export -> Select All Tables -> Adjust Options -> Go.
You are going to get <youdatabasename>.sql file, with all the table definitions inside. Then you can import it in another phpMyAdmin or other database handler.
You can use mysqldump to do this. Then --nodata switch should do what you want.