SQL Query Using External Table
SQL Query For Retrieving Data From Excel
Topic Introduction: Sometimes we need to show data from Excel or CSV files. which data is not stored or our database table. Today we will show SQL Query for Retrieving Data From Excel Using an external table. Or how can we read an Excel or CSV file by SQL Query?
Steps need to follow to retrieve data from an external file
- Selected CSV or Excel files are kept in your computer Directory.
- Create a Directory
- Grant Directory to User
- Create a table for external file
- Query Execute for Check Data
CREATE DIRECTORY LANG_EXTERNAL AS 'D:\Loader';
GRANT READ, WRITE ON DIRECTORY LANG_EXTERNAL TO HR;
CREATE TABLE LANGUAGES(LANGUAGE_ID INT,LANGUAGE_NAME VARCHAR2(30))ORGANIZATION EXTERNAL(TYPE ORACLE_LOADERDEFAULT DIRECTORY LANG_EXTERNALACCESS PARAMETERS(FIELDS TERMINATED BY ',')LOCATION ('languages.csv'));
SQL Query to get data from Excel.
SELECT LANGUAGE_ID, LANGUAGE_NAMEFROM LANGUAGESORDER BY LANGUAGE_NAME;
CSV File Data Format
SQL Query From Excel File |
No comments