when I copy paste some data from the results tab of the sql server to new query tab it paste in a single line - settings

whenever I try to copy and paste some data from results tab of MS SQL SERVER which is fetched by a query is pasting in a single line.
Did have to change any settings..?

Related

Run multiple queries in SQL PLUS

I am beginner at using SQL and I have searched a lot but couldn't solve that issue. I have about 2500 lines of queries and I need to run all these lines in one shot. When pasting those lines to SQL PLus editor it just executes about 75 lines and ignores the rest of lines
Can you guide me please of how to do that?
Thanks advanced for help
Put your SQL statement(s) in a script file and execute it
For instance : open notepad. Paste your SQL. Save the file on your desktop and name it test.sql
Then in SQL plus prompt, just do this :
SQL > #C:\Users\YourName\Desktop\test.sql
(the # is the trick)

How to export large amount of data using sql developer - Oracle

I want to upload some data from UAT DB to DEV DB. When I try to do this from Export function in SQL Developer, I got an error File C:\Users\xxx\export.sql was not opened because it exceeds the maximum automatic open size
How can I copy the UAT data to DEV ?
ORACLE Version 12C
SQL Developer Version 4.0.0.13
found the below answer from a SQL Developer forum :
It appears that the "maximum automatic open size" is hard-coded to a value of 500000 (bytes, I believe) with no way to override it. By
limiting this, we nip in the bud any potential complaints of Java
OutOfMemory upon trying to open a huge file.
To view the file from within SQL Developer despite this limitation,
just use the File|Open menu. For those huge files, please use an
external editor. And if you don't want to open files automatically in
order to suppress the warning dialog, use
Tools|Preferences|Database|Export/View DDL Options and un-check the
"Open Sql File When Exported" box.
Are you certain the export file does not contain all the insert rows?
That would be a bug unless you hit an OutOfMemory or disk full
condition. I just tried your scenario on at 55000 row table that
produced an export.sql of about 20MB. All rows were included.
Regards,
Gary Graham
SQL Developer Team
and as the summary, it suggested that the SQL developer is not the best tool to open a large size of data file.
hope Gary's answer will guide you to some extent.
If you need to get an idea of some tools that you can open large files, check this LINK
Solution 1:
Set these values to some higher value!
Solution 2:
change "save to" to worksheet!
I was having this error when exporting database in insert format, selecting loader format on the 1st Export wizard screen fixed the issue.
This is probably because insert format creates a single SQL script with DDL and data as insert statements. So all the database is dumped in a single script file.
loader option produces multiple files: control file, data file, and sql files. And there are separate files for each table. As a result the export will consist of hundreds of files and no one file will reach the size limit.
This may not however work with single tables with very large amounts of data as that table's data file would hit the limit.
You can try different options like below.
On SQL developer, when right click on Table and click export, export wizard will be launched you can select either "Save As" - "separate files" that will export data in same SQL file.
OR you can change the format type on the same wizard to CSV that will export data in CSV format.
If you want to transfer large amounts of data (or small amounts, too) from one database to another, you should consider the tools that were specifically designed for such tasks.
First and foremost, look into data pump. It has a bit of a learning curve, though.
exp and imp (also by Oracle) are a bit easier to handle, but they're older and not nearly as powerful as data pump.
You might also want to look into the SQL*Plus copy command.
There is a trick to copy large chunk of data (from SQL developer) into excel sheet.
steps to be followed : Right click ---> export data ----> select format type as 'Text' ---> select type as "Clipboard" ----> open an excel sheet and try to paste keeping the below in mind :)
Then paste the data
NOTE : **Do Not paste the data on the first cell of the excel. Ctrl+v in any of the columns **
This will work.
Thanks
You can use spool the query and save the results as CSV or XLSX files for larger results. For example:
spool "D:\Temp\Report.csv"
SELECT /*csv*/ select id,name,age from EMP;
spool off;
1-You can create a database link (db link) on DEV DB pointing to UAT DB, to INSERT rows in DEV DB.
2-Or you can build in PL/SQL a procedure in UAT DB to export data to a file in CSV format and in DEV DB use oracle external tables to SELECT from that files.
Be carefull about DATE acolumns, write down using TO_CHAR.
3-Use Datapump to export data from UAT DB and then import into DEV DB; it's a bit tricky.
Oracle database commands can run both in SqlCl by Oracle and in SQL developer, so this is easy:
set feedback only -- for Oracle 12.2+, turn off terminal output
set sqlformat insert -- data in "insert into ..." format
-- set sqlformat csv -- data in csv format
spool /path/to/your/file.sql
select * from t; -- lines to export
spool off
set feedback off -- restore terminal output
Simplest way to this is to modify the "Save As" below in the screenshot to save to multiple files instead of single file while exporting-

How to copy data from one database/table to another database/table in oracle using toad

I am trying to copy a table data from dev box db to uat db which are 2 different data bases . I am trying in toad.All the connection details are correct but its not working and throwing the following error.
[Error] Execution (12: 1): ORA-00900: invalid SQL statement
This is what i am trying
copy from abc/cde#//abc.abc.com:1521/devbox to abc/cde#//abc.abc.com/uatbox
INSERT TOOL_SERVICE_MAPPING (*)
USING (SELECT * FROM TOOL_SERVICE_MAPPING)
If your table doesn't have a huge number of rows you can use Toad's Export function: it creates an insert statement for each row. You can then run these statements in destination DB to re-create your table's data.
Here are the steps:
A. Create a copy of the table in destination DB
in source DB in a schema browser window click on the table you want to copy, select "script" tab in the right part of the window: you will find the script to re-create your table; copy this script
paste the script in a new SQL editor window in destination DB and run it. This should create the new table
B. Copy data in new table
in a schema browser window right click on table name in source DB
select "Export Data" from context menu
write "where" statement of your export query (leave it blank if you want to copy the entire table)
select destination: clipboard
click "ok" (now insert statements are stored in your clipboard)
paste insert statements in a new SQL editor window in destination DB
run statements as script (shortcut F5)
copy is a SQL*Plus command, not a SQL statement. I would be surprised if Toad had implemented that particular SQL*Plus command (it does implement many of the simpler commands). If you want to use the copy command, you would need to use SQL*Plus, not Toad.
If you want to use Toad, you would need to use a SQL statement to copy the data. You could create a database link in the destination database that points to the source database and then
INSERT INTO tool_service_mapping
SELECT *
FROM tool_service_mapping#<<db link to source database>>
The easyest and most error-free way I have experienced so far is: Database->Compare->Schemas
It's not too complicated as it looks (lots of checkboxes), but you tick boxes for objects you need to be created in an empty database, and at the end of comparison you end up with SQL script including all objects (triggers, views, sequences, packges) that you selected (checkboxes).
I clearly see all tables, triggers, data, etc in generated sql script and even can tick these I don't wish to create (if any)... Before executing script, TOAD asks you to confirm against which database you are running the script - saved me few times... As ackward as it looks, it works perfectly.
I have arround 200 tables I don't know if this is suitable for huge databases.

Save queries in VFP

How to save queries on disk.I use the TO clause(example:SELECT * FROM vendors TO w.qpr).Everything works,but when I run the query with DO i receive the following error:
http://s52.radikal.ru/i138/1201/2f/15765ffe2346.png
And what should I change in order to obtain the query like in query designer,I mean that the query should appear in browse window,but using the command mode.
Thank you in advance.
The TO clause is for storing the results of the query, not the query itself. (And, TO is a VFP extension; INTO is preferred.)
If you want to save the query, open up a PRG file (MODIFY COMMAND) and write the query there, then save it.
If you simply omit the TO or INTO clause, the query results will appear in a BROWSE window. Alternatively, use INTO CURSOR and give a cursor name, then issue BROWSE to browse the cursor.
Tamar
As in the other answer, use MODIFY command to make a .prg for your select code.
The INTO clause is for the result.
SELECT * FROM zip INTO CURSOR c_zip
Or
SELECT * FROM zip INTO TABLE c:\temp\test
If you want a XLS or CSV or something, select into a cursor then use
EXPORT TO c:\temp\zip.csv XL5
To save a query file
Do File, New, and select QUERY radio button.

Oracle SQL Developer: how to get back the SQL statement that had been executed?

In SQL Developer, you can pin the query result. After running dozens of querys, it is hard to find certain one from history or SQL worksheet, but you probably know which query you are looking for by viewing the pinned query results. If you put your mouse at the tab of the pinned query result, the executed SQL to generate that result is shown as a tool tip, however, I don't know how to copy that SQL statement and exeture it again. Can anyone help?
If all you want to do is re-execute the query, from the pinned query result window you can click on the Refresh button.
If you want to copy+paste the statement in order to modify it before re-executing, in the pinned query result window there is an SQL button that will show you the sql command used and will let you copy it.
(I am using SQL Developer 3.1)

Resources