Populating tables in SQL Developer using data from a file - sql

I have a txt file containing a table with two columns student ID and GPA. I want to create a similar table in Oracle SQL developer. Is there some way to copy this data directly into SQL developer

If you are looking for a simple GUI method, you can connect to a db, right click on "Tables", "import data..." and use the Data Import Wizard.
Select the correct options (csv/delimited, tableName, cloumnsToImport...) and click "Finish".
Sorry, I cant post pics yet see the example screenshot here: http://i.stack.imgur.com/S7HFx.png

You can create external table with that file, then copy the external table into a new internal table (usual table), here is a full example:
External Tables Concepts
Then go to:
Example: Creating and Loading an External Table Using ORACLE_LOADER

Related

Problem appending CSV upload to existing BigQuery table

I've been used to quickly uploading a CSV file to append data to an existing table in BigQuery.
I've made the new table name the same as the existing table, and I've then had options to overwrite or append data to the existing table.
This seems to have changed in the past few days and there is a new BigQuery console UI.
When I try and create a new table from a CSV file upload, under the table name field it currently says:
Unicode letters, marks, numbers, connectors, dashes or spaces allowed.
The job will create the specified destination table if needed, or the
table must be empty if it already exists.
However, when I try and create a table with the same name as an existing table (even though the existing table is empty), I get a red warning saying:
Table already exists
Does anyone know if this feature has now been removed or how to easily append data?
The long way round is to upload a CSV to a new table, then query the new table and set the destination to append or overwrite an existing table. Not ideal, particulalry having to define a new table schema.
In order to append a CSV file to an existing BigQuery table when using the Console, please follow the instructions below:
In the Explorer panel, expand your project and select a dataset.
Expand the Actions option and click Open.
In the details panel, click Create table.
On the Create table page, in the Source section:
For Create table from, select Upload.
Browse file from system
On the Create table page, in the Destination section:
For Dataset name, choose the appropriate dataset.
In the Schema section, for Auto detect, check Schema and input parameters to enable schema auto detection. Alternatively, you can manually enter the schema definition
Click Advanced options.
For Write preference, choose Append to table
Please review this document that expands on the same topic.

Copy 10k rows from table to table on other server

I cannot use linked server.
Both databases on both servers have the same structure but different data.
I have 10k rows to transfer from the DB on one server to the same DB on the other. I cannot restore the DB on the other server as it will take a huge amount of space that I don't have on the other server.
So, I have 2 options that I don't know how to execute:
Backup and restoring only one table - the table is linked to many other tables but these other tables exist on the other server too. Can I somehow delete or remove the other tables or make a backup only over one table?
I need to transfer 10k rows. How is it possible to create 10k insert queries based on selected 10k rows?
Can I somehow delete or remove the other tables or make a backup only over one table?
No you can not do this, unfortunately
How is it possible to create 10k insert queries based on selected 10k rows?
Right-click on Database -> Tasks -> Generate scripts -> (Introduction) Next
Chose Select specific database objects -> Tables, chose table you need -> Next
Advanced -> Search for Types of data script change from Schema only (by default) to Data only -> OK
Chose where to save -> Next -> Next. Wait the operation to end.
This will generate the file with 10k inserts.
Another way is to use Import/Export wizard (the most simple way for one-time-import/export) if you have link between databases.
There are many ways to choose from, here is one way using BCP. That's a tool that ships with SQL Server to Import and Export Bulk Data.
The outlines of the process:
Export the data from the source server to a file using BCP - BCP OUT for a whole table, or BCP QUERYOUT with a query to select the 10k rows you want exported
Copy the file to the destination server
Import the data using BCP on the destination database - BCP IN.
My suggestion would be to export these rows to excel( you can do this by copy pasting your query output) and transfer this to other server and import it there.
this is the official method :-
https://learn.microsoft.com/en-us/sql/relational-databases/import-export/import-data-from-excel-to-sql
and this is the the unofficial method :
http://therealdanvega.com/blog/2010/08/04/create-sql-insert-statements-from-a-spreadsheet.
Here I have assumed that you only need to transfer the transactional data and your reference data is same on both server. So you will need to execute only one query for exporting your data
I would definietely go down the SSIS route once you use SSIS to do a task like this you will not use anything else very simple to script up. You can use any version and it will be a simple job and very quick.
Open new SSIS project in available visual studio version/s there are many different but even a 2008 version will do this simple task you may have to install integration services or something similar used to be called bids (business information development studio in 2008) (anything up to 2015 although support is nearly there in 2017)
add a data flow task
double click the data flow task
Bottom of screen add two connection managers (1 to source and 1 to destination database)
add oledb source pointing to source database table
add oledb destination pointing to destination database table
drag line between the source and destination (should auto map all columns if the same name)
hit Start and the data will flow very quickly
you have create DbInstaller. using dbInstaller you have share whole database. Dbinstaller work both ado.Net and Entity Frame Work but I have using Entity Frame Work.
you can do it by sql server query
first select first database like
Use database1 --- this will be your first database
after select first database we will put our table row in temp table by this query
select * into #Temp from select * from table1
now we select second database and insert temp table data into second database table by this code
use secondDatabaseName
INSERT INTO tableNameintoinsert (col1, col2, )
SELECT col1, col2 FROM #temp;

transfer single table data from one Database to other database with same table name?

How can i transfer single table data from one Database to other database with same table name?
I have a database with data and other one has no data.
They are not exactly the same as but one table is the same
Thanks
There are many ways to export a table. Some are,
Using SELECT INTO Query
Select * into Database1.Department from Database2.Department
Using SQL Server Export / Import wizard
a. From SQL Server Management Studio, right-click on the database name in the object explorer, then choose Tasks -> Export Data
b. Choose a Data Source and Destination
c. Select the source table and follow the steps and execute the package
For more info, check http://www.sqlshack.com/how-to-copy-tables-from-one-database-to-another-in-sql-server/
Edited Note:
The above methods are for Microsoft SQL Server.

Finding rows in table using input from a CSV file - SQL

Using a SQL tool like SQL Developer / Toad for Oracle
Is it possible to write a SQL query that will do the following
SELECT * FROM TABLE
WHERE COLUMN1 IN CSV_FILE
The CSV file is just one column of data with no delimiters.
How can I achieve this?
Constraints
I cannot create a temp table to insert CSV file (no create permissions)
The data I am using of this column is the only index in that table so I cannot use other columns to query or else it will be really slow.
Thanks
Creating external table is the best way. If you dont have permission then the other way is to move the file to the path of any oracle directory(Oracle object - Directory). And with help of utl_file read the file, loop through it and do your operation inside a PL/SQL block which is too tedious.
See the eaxmples for using utl_file - http://psoug.org/reference/utl_file.html
But its better if you try and get create access.
Toad for Oracle data import (uses sqlldr internally)
Create a temp table and load the data using this utility and select the values
External tables
Create external table, load the data through the same and select the values.
Using SQL developer you can create a table in your schema and load this table with data from a csv file.
Notes:
You will need to create a void column per each column to import from excel
Excel export csv with ";" delimiter
If SQL developer(4.1.5) doesn't preview the fields in separated columns try moving forward/backwards with Next/back buttons
and a very graphical guide in the following page:
http://www.thatjeffsmith.com/archive/2012/04/how-to-import-from-excel-to-oracle-with-sql-developer/

Oracle 10g- exporting and importing Table

I need a command for importing a table for the following scenario.
I have a table EMPLOYEE in server A. I am exporting the Table.
I have another table PDATA(having same structure of EMPLOYEE table) in server B.
I need to import the records from EMPLOYEE table(server A) into PDATA table(server B).
I am using Oracle 10g. Please advise.
There are a couple of options. I am going to assume that you don't have any binary data and that the tables aren't absurdly large. We also don't know what type of access you have to either server.
You could use a tool, such as TOAD, to either export to csv or create insert statements. Then execute those on the second server.
You could use PL/SQL and the UTL_FILE library to dump the contents of the table to a csv file. Then mount the csv file as an external table and select into your new table.
If you have the appropriate permissions and the machines can physically see each other you can setup a database link: http://docs.oracle.com/cd/B14117_01/server.101/b10759/statements_5005.htm Once the link is created, you can select from one table into the other.
If you are a DBA then you can use the Export utility, which will export the table into a binary format that can be imported elsewhere.