export data from database in liquibase format - postgresql

is it possible to export data in liquibase format from already exist postgresql database? until today i each time when i run my project in groovy grails i was using bootstrap file where i was generating everything to database. to export schemas i used grails dbm-generate-changelog and works fine. i used configure tutorial from http://grails-plugins.github.io/grails-database-migration/2.0.x/index.html
best regard!!! :-)

You can use a regular SQL Dump from your DB in the liquibase migrations with minor effort:
Create your SQL file and put it under grails-app/migrations. E.g.
grails-app/migrations/2016-03-17-002-activiti-5.19.0.2.mysql.create.engine.sql
Add that file to your changelog.groovy
Add the following preamble to the SQL file
--liquibase formatted sql
Separate your SQL file into sections you want to see as changesets (add at least one at the beginning):
--changeset activiti:5.19.0.2-create-engine
See the docs: http://www.liquibase.org/documentation/sql_format.html

Related

Run SQL script on multiple schemas with Flyway

I am migrating the DB using Flyway. I have a SQL script file which need to run on multiple schemas hosted on a single database.
In my SQL file if I mention ${db_schema} as the parameter and supply with different schema names, will that work? Is there any other approaches to handle this scenario?
SET search_path TO ${db_schema};
You should be able to use placeholders in flyway to handle more than one schema. Here's an article that outlines how that works.

How do i dump data from an Oracle Database without access to the database's file system

I am trying to dump the schema and data from an existing Oracle DB and import it into another Oracle DB.
I have tried using the "Export Wizard" provided by sqldeveloper.
I found answers using Oracle Data Pump, however i do not have access to the filesystem of the DB server.
I expect to get a file that i can copy and import into another DB
Without Data Pump, you have to make some concessions.
The biggest concession is you're going to ask a Client application, running somewhere on your network, to deal with a potentially HUGE amount of data/IO.
Withing reasonable limits, you can use the Tools > Database Export wizard to build a series of SQLPlus style scripts, both DDL (CREATEs) and DATA (INSERTs).
Once you have those scripts, you can use SQLPlus, SQLcl, or SQL Developer to run them on your new/target database.

How to make Oracle SQL Developer export NLS-safe SQL dumps?

I used Tools -> Database Export in Oracle SQL Developer 18.2.0 to generate full schema and data dump.
Then I attempted to use that dump in a shell script calling sqlplus and got the following error:
Insert into CONN.ACCOUNT (ID,CUSTOMER_ID,LAST_MODIFIED) values ('1','1',
to_timestamp('2018.09.06 17:45:29,000000000','RRRR.MM.DD HH24:MI:SSXFF'))
*
ERROR at line 1:
ORA-01830: date format picture ends before converting entire input string
Most probably, that was caused by NLS settings in Oracle SQL Developer 18.2.0. I did not touch them, SQL Developer seems to have picked them up from default Windows settings.
Is there any way to make Oracle SQL Developer generate safe export dumps that could be later imported through sqlpus without manually hunting for all required NLS settings and adding them at the beginning of the sql dump file?

How to run a SQL Script that builds my DB and schema in OrientDB?

I'm using OrientDB 2.0.2. I'm writing a SQL script that will create a new DB, construct the schema, and then populate the DB with static initial data. I know that the database will be automatically created if I simply start loading data, and that classes will automatically be created if I start inserting records, but I want to make sure that my classes have the right inheritance and Properties and Indexes before I begin my data load.
The SQL syntax is easy - I just need to know how to run the SQL script from the command line in order to instantiate the the DB, as if I were deploying a new instance of my DB at a new location, or for a new customer.
Thanks.
Assuming you installed OrientDB in the base directory ORIENTDB_HOME, then go to the $ORIENTDB_HOME/bin directory. In this directory, execute the OrientDB SQL Script with the simple command:
*nux:
$ ./console.sh myscript.osql
Windows:
> console.bat myscript.osql
mysql.osql is a simple text file, containing all SQL command (.oslq is a typical file extension for OrientDB SQL scripts).
See documentation for details how to create a new database. Example:
CREATE DATABASE plocal:/usr/local/orient/databases/demo/demo
or
CREATE DATABASE remote:localhost/trick root verySecretPassword

How to export data from SQL Server to PostgreSQL?

I need to export all tables from SQL Server to PostgreSQL.
Try: I tried from SQL Server IDE but at some stage its giving the error about data types are different.
Question:How can I do export of data from SQL Server to PostgreSQL? Is COPY does my job? If yes, then how can I export all tables including records?
You can't export data from MSsql then import to PostgreSql because it is not same syntax, data type, but you can use tool to migration data from mssql to postgreSql,
See more in topic
migrate data from MS SQL to PostgreSQL?
Use https://dbeaver.io/
Create MS SQL and PostgreSQL database connections (login)
Create target tables in PostgreSQL (same structures in MS SQL)
F5 to see new tables
Right-click on new tables -> 'Import Data' -> You will see 'Data Transfer' window
Choose 'Table' type then click 'Next' -> You will see 'Select input object', where you can choose tables from MS SQL connection
Just 'next' and check settings that you need, done :D
First export the schema into a file and run it against PostgreSQL until you've removed all incompatibilities.
You could try to do the same with the data you want to export but you may be better off writing a Python script to migrate it.
There is an absolutely simple way using built-in SSIS tool using Management Studio. You can find the detailed answer here.
Use https://dbeaver.io/ , as An Le mentioned.
After 40 years of DB development, migrating DB data is still a challenge. DBeaver is a free tool to use for data migration. But you still have to migrate the schema.
Exporting data from DBeaver
From contextual menu of your SQLServer database or schema select Tools > Create new Task > Common > Data Export
You will generate SQL insert files or CSV files. For migration between database types use CSV files.
Cons of SQL Server Migration Tool
Unable to migrate rows containing booleans.
Export ended up in errors of migrationg data with Bool columns, complaining that value is not boolean, although both source and destination columns where of boolean type.
Unable to continue with the next tables afer one table migration fails.
SQL Server - A single error stops all migration even for tables that are not related to the initial error.
Configuring the tool over and over again, trying to export your data is a waste of time. SQL Server migration task does not save the configuration of the source and destination connections. And the wizard is not user friendly, spending your time on it is frustrating. I assume the migration project was abandoned for at least 10 years.