Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I import file with SQL commands?

I have a simple problem, but I can't find out how to solve it.
I have a file which contains many SQL commands, like this:

insert into .. ;
insert into .. ;
...

And now is the question - how do I import it?
I was trying to import script, but it doesn't work, I'm getting:

Your export file is not supported

When I'm copying my commands manually, it's works. But I can't copy them all, it will take too long.

I'm using Oracle DB 11g XE.

Any solutions?

like image 589
marxin Avatar asked Nov 25 '11 10:11

marxin


People also ask

How do I import a file into SQL?

Open SQL Server Management Studio. Connect to an instance of the SQL Server Database Engine or localhost. Expand Databases, right-click a database (test in the example below), point to Tasks, and click Import Flat File above Import Data.


2 Answers

You need a SQL interpreter for Oracle. The one that is bundled with every Oracle client installation is called SQL*Plus. And will do what you need to import a file with SQL commands.

You login with it to your Oracle server and then run your script. Let's say your Oracle connection is called mydb and your schema name is scott and your SQL script is stored in a file called myfile.sql. What you can do is:

$ sqlplus scott@mydb

To login to oracle (you will be prompted with your password). And then, once you are inside SQL*Plus, you can do:

> @myfile.sql

Done.

like image 60
Pablo Santa Cruz Avatar answered Oct 04 '22 14:10

Pablo Santa Cruz


Use SQL*Plus or Oracle SQL developer.

With SQL*Plus:

sqlplus <schema>/<pw> @<your_script.sql>

With SQL Developer, open your script, and then "run as script" (F5 I think).

like image 35
Vincent Malgrat Avatar answered Oct 04 '22 14:10

Vincent Malgrat