Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 236
tomaytotomato Avatar asked May 30 '26 00:05

tomaytotomato


1 Answers

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.

like image 199
DB_learner Avatar answered Jun 01 '26 17:06

DB_learner



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!