Fetch table query in Oracle database for data extraction? - oracle

I want Oracle SQL Developer to create a SELECT statement "automatically" for the table that are in databse, I want the table query for extraction and so that I do not have to type for all.

Let me guess: you want SQL Developer to create a SELECT statement "automatically". If so, then drag table into the editor and choose an option:
Result:
SELECT
ename,
job,
sal,
comm
FROM
bonus;

Related

how to get the DDL of a table with different schema

I have few databases and all the databases have the same tables (i.e. table names). Now i want to get the DDL of the table with different schema.
Use the dbms_metadata package to get the DDL of any object of the DB.
SELECT
DBMS_METADATA.GET_DDL('<Object type>', '<Object name>', '<object schema>')
FROM
DUAL; -- How to
SELECT
DBMS_METADATA.GET_DDL('TABLE', 'MY_TABLE', 'MY_SCHEMA')
FROM
DUAL; -- In your case use something like this
Also, You can format the output using dbms_metadata.set_transform_param.
See Oracle documentation for more information on it.
Cheers!!

CTE (With table as) in sql server equivalent in hive?

I use WITH table_name AS (select...;) command in SQL Developer to create temporary table and use that temp table in following queries. What is the similar command in Hadoop Hive?
Using SQL assistant User interface on Hadoop Hive.
I tried the following example, which gives error-
Create table Failed,80:
CREATE TEMPORARY TABLE temp1(col1 string);
CREATE TEMPORARY TABLE temp2 AS Select * from table_name;
Maybe you must write case sensitive like this:
CREATE TEMPORARY TABLE temp1(col1 STRING);
The same CTE as in MySQL:
with your_table as (
select 'some value' --from etc etc
)
select * from your_table;
Another example: https://stackoverflow.com/a/54960324/2700344
Hive CTE Official docs

how to extract tables attributes like column name , datatype ,nullable for all the tables from the database from oracle pl/sql

Is there any query that can be used to retrive the Tables and its column attributes like column name , datatype, nullable etc for all the tables inside the database
For Oracle Pl/SQL
The Oracle SQL you need would be the following (run as user 'SYS'):
select owner, table_name, column_name, data_type, nullable
from dba_tab_columns;
If you do a desc dba_tab_columns you will get a list of many more columns which may be of interest to you as part of your result set.
You can use a SQL tool (i.e. SQL*Plus) to run this query or you can use PL/SQL to call this query and put the results in PL/SQL variables then print them out via DBMS_OUTPUT.PUT_LINE().
HTH

selecting huge data in oracle

I have to select data form a table under Oracle 10.The statement I have simply used is
select * from table_name;
After the execution of the statement it first fetches 50 rows.
Thenafter I just select ctrl+A to select all the rows and export it to a csv file.
But it is taking a lot of time.
Is there a better way to fetch all the rows and capture the data to csv?
You can use Oracle SQL Developer tool connect to database and right click on Table which is the table you want export the data then select Export option there you can select Format as CSV
or
After select * from table_name; go to result then right mouse click, then select Export then select Format as CSV and select the path where you want save then then Next then Finish

Select from one DB and insert in another DB

I need a sql query in which
Select from DB1 and insert into DB2 in one single query
Example:
DB1
Select username,account_status from dba_users;
DB2
Insert into table User_id
You have to create a database link (this should probably be done by a DBA). Once that is in place, you can select from the other database and write a statement like this:
INSERT INTO MyTable
SELECT * from MyTable#DB2
[Edit]
You can't without a database link.

Resources