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

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?

Related

Connect Oracle database with SQLcl

I am using sqldeveloper to query database and export results to csv file. I need this file on daily basis so thought of creating bat file which can be scheduled on windows task scheduler. I was researching it and found I can use SQLcl to run my script to export the query data. But somehow I can't connect it and it gives me and error 'ORA-01017: invalid username/password;logon denied. Here is my connection properties from sql developer
Here is my command line:
sql testuser1/mypass#tstwd2.myhost.internal:1521/tst.internal
I have java development kit installed
Do I need anything for java? Or do I need any special rights to run sql command line?
Found the problem, my userid is in double quotes so I have to use escape sequence **\**, its working like a charm.

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.

export data from database in liquibase format

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

Export ixf in db2

EXPORT TO myFile.ixf OF ixf SELECT * FROM TABLE_NAME WHERE SSN='DATA' AND EMPLOYER_ID=DATA AND CREATED_TS='DATA'
I am using this statement to export a couple of rows. for privacy purposes DATA has been inserted where necessary. however the following error is produced. I have followed IBM's guide on export and feel like this should be correct but unsure exactly as to what is wrong. the error log is as follows
Error: DB2 SQL Error: SQLCODE=-104, SQLSTATE=42601, SQLERRMC=myFile;EXPORT TO ;JOIN, DRIVER=3.53.70
SQLState: 42601
ErrorCode: -104
As already remarked, you cannot directly run Db2-commands (such as import, export, load ... etc.) from plain SQL , as you are trying to do via JDBC.
Instead, if your Db2-server runs on Linux/Unix/Windows, you can either use a stored procedure, or (for any Db2-server operating system) you can use the command-line.
However, when you use stored-procedure SYSPROC.ADMIN_CMD for Db2-LUW, all file-names in stored-procedure parameters are relative to the Db2-server (and not your remote jdbc-client, if you are running remotely).
That means after a successful export via stored-procedure, if you really need the exported IXF file to be on your workstation then you must do file-transfer to your workstation using whatever tools you have for that purpose.
For example, this shows an export on Unix to an IXF file in /tmp on the Db2-server:
call sysproc.admin_cmd('EXPORT TO /tmp/myFile.ixf OF ixf SELECT * FROM user1.stk1 with ur') ;
If you don't want to use a stored procedure, you must use the command-line shell (for example on Windows, use db2ntcmd.bat , or on Unix use bash or ksh) and connect to the database in the shell and perform the export. This requires the workstation to have a Db2-client and also that the relevant database and node be first catalogued.
If you specify your Db2-version and the operating-system on which your Db2-server runs, then you will get more details.

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.