Select the data in two tables
Hello
I am trying to build a query WITH, but I can't seem to make it work:
WITH P1 AS (SELECT OT_VALUE
OF CSD_OPEN_VERY_HIGH_INCIDENTS VHIGH
WHERE OT_VALUE > = 0
). P2 AS (SELECT OT_VALUE
OF HIGH CSD_OPEN_HIGH_INCIDENTS
WHERE OT_VALUE > = 0
), SELECT VHIGH. OT_VALUE, TOP. OT_VALUE
P1 P2 JOIN INTERNALLY. RATING = P2. RANKING
The two tables have the same column names.
I want to only return a set of results if the two columns (OT_VALUE) contain in reality 1.
Select this check box. This is a job for all four images. This will return the line to the following combinations. 0.0 and 0.1 and 1.0 and 1.1. Importance is 1.2. Let me know if you face any problem
SELECT CASE WHEN ((VH_OT_VAL = 0 ET H_OT_VAL = 0) OR (VH_OT_VAL = 1 AND H_OT_VAL = 0) OR (VH_OT_VAL = 0 AND H_OT_VAL = 1) or (VH_OT_VAL = 1 AND H_OT_VAL = 1)) 1
ANOTHER ACE OF NULL TERMINATOR OT_VAL
DE)
SELECT H.OT_VALUE H_OT_VAL,
VH. OT_VALUE VH_OT_VAL
OF CSD_OPEN_VERY_HIGH_INCIDENTS VH.
CSD_OPEN_HIGH_INCIDENTS H
WHERE NVL (VH. CLASSIFICATION, 0) = NVL(H.CLASSIFICATION,0)
AND VH. IMPORTANCE IN (1,2)
AND H.IMPORTANCE IN (1,2)
AND NVL (VH. OT_GROUP, 0) = NVL(H.OT_GROUP,0)
AND VH. IMPORTANCE = H.IMPORTANCE
AND VH. TIME_STAMP = H.TIME_STAMP
);
Tags: Database
Similar Questions
-
Kindly help me with the request to find the data in two tables
Hello Guru
Kindly help me to recover the data from two tables-
BASEBALL
LEGAL_ENT_ID (PK)
GAME_ID (FK)
LEGAL_ENT_NM
INACTIVE_DT
DATE OF INS_TS
INS_LOGIN
DATE OF UPD_TS
UPD_LOGIN
FOOTBALL
GAME_ID (PK)
BRKR_NM,
BRKR_ISR_ID
BROKER_SYMBOL
INACTIVE_DT
BRKR_SWIFT_FLG
BRKR_INTERNAL_FLG
BRKR_CATEGORY
UPD_TS
MINORITY_FLG
BROKER_TYP
STATUS
INS_TS
INS_LOGIN
UPD_LOGIN
APP_USER
ACTIVE_FLG
and if I want fecth data from these two tables according to the following condition then it is fine with the suite of applications.
1 select distinct values only table of BASEBALL by using the following query.
SELECT DISTINCT B.GAME_ID as 'CLEARING GAME ID', B.BRKR_NM "NAME of THE GAME of COMPENSATION" OF BASEBALL A, FOOTBALL B WHERE A.BROKER_RELATION_CD IN ('FUTBRKR1', 'FUTBRKR2') AND A.GAME_ID = B.GAME_ID
2 Select all the table BRKR_NM OF FOOTBALL as well by using the query - next
SELECT GAME_ID "RUNNING GAME ID", 'NAME OF THE GAME OF EXECUTION' BRKR_NM SOCCER
Now, my query is that--
I want a query that gives me a combination of above mentioned queries... and if I tried to use Union or Union All, then she is not giving me the result as expected.
I like the result to look like who has a few conditions such as -
1 - the records in the table Football are high vs Baseball table because there is no condition to filter the records of the Football.
2 - football is a superset of records and Baseball is a subset.
3 - COMPENSATION NOM_JEU and RUNNING NOM_JEU may return the same values as well.
I want the result to be in the following form-
EXECUTION ID GAME | NAME OF THE GAME TO RUN. COMPENSATION ID GAME | DELETE THE NAME OF THE GAME.
2123 test1 2345 test5
2456 test10 2456 test10
Thanks in advance. Kindly help me.
Published by: user555994 on January 4, 2011 23:48In the output you want.
All the values of baseball;
Values of football that are matched;
But on what condition you want to match? -
Select the data in a table and update in another table
Dear experts,
create the table TB_ENCRYPT
(
Identification number,
Varchar2 (200) KEY
);
INSERT INTO TB_ENCRYPT VALUES(1,'HJUVHDUIFBSDGVU');
SELECT * FROM TB_ENCRYPT;
1 HJUVHDUIFBSDGVU
create TABLE users)
username, NUMBER of
password VARCHAR2 (200)
);
Insert users
values (1, 123 # "")
Insert users
values (2, 456 #')
Select * from users;
1 123 #.
# 2 456
I want to select the data KEY for table TB_ENCRYPT column and update in the column of tables for the respective key user password
TB_ENCRYPT table contains only a single key value. Comparing this key, I want to update the old value of the key to the new value.
For encryption and decryption I followed the java class method.no is worried about that.
create or replace
PACKAGE PCK_ENC AUTHID CURRENT_USER AS
FUNCTION DECRYPT (VARCHAR arg0, arg1 VARCHAR) AS VARCHAR BACK LANGUAGE JAVA NAME 'Encrclass.decrypt (java.lang.String, java.lang.String) return java.lang.String ';
FUNCTION ENCRYPT (VARCHAR arg0, arg1 VARCHAR) AS VARCHAR BACK LANGUAGE JAVA NAME 'Encrclass.encrypt (java.lang.String, java.lang.String) return java.lang.String ';
END;
SELECT PCK_ENC. ENCRYPT('1234','HJUVHDUIFBSDGVU') FROM DUAL;
HERE,
1234 - is the password of the users table column data
HJUVHDUIFBSDGVU - represents the key of table TB_ENCRYPT column data.
Comparing this key, I want to update the old value of the key to the new value.
I tried with this method
declare
cursor c1 is
Select the key
of TB_ENCRYPT
where id = 1
update the id;
Start
for c1_rec looping c1
update users
password is PCK_ENC. Encrypt (Password, Key)
the location being c1;
commit;
end loop;
end;
/
Help, please
You can use the MERGE statement.
merge into users using tb_encrypt on (id = userid) when matched then update set password = PCK_ENC.ENCRYPT(password,key);
And why you encrypt your password. This isn't a good idea. Just password hash.
-
How to find the data in two tables are the same?
Hi people,
Suppose we have table emp01, have 10 records and create another emp02 as table
create the table emp02 in select * from emp01;
now both the table has the same data.
How to find a 'data' in the two tables are the same?Hello
SELECT * FROM emp01 MINUS SELECT * FROM emp02 UNION SELECT * FROM emp02 MINUS SELECT * FROM emp01
You can also compare resultset hash to select * in emp01 and select * from emp02 by using dbms_sqlhash.
Best regards
Nikolai -
display the data in two tables.
Hi considers the following data
I want to join these two tables and result the followingWITH table1 AS ( SELECT 111 userid, To_Date('7/31/2010','mm/dd/yyyy') dt FROM dual UNION ALL SELECT 111 userid, To_Date('8/1/2010','mm/dd/yyyy') dt FROM dual UNION all SELECT 111 userid, To_Date('8/2/2010','mm/dd/yyyy') dt FROM dual UNION ALL SELECT 111 userid, To_Date('8/3/2010','mm/dd/yyyy') dt FROM dual UNION ALL SELECT 111 userid, To_Date('8/4/2010','mm/dd/yyyy') dt FROM dual UNION ALL SELECT 111 userid, To_Date('8/5/2010','mm/dd/yyyy') dt FROM dual UNION ALL SELECT 222 userid, To_Date('2/28/2010','mm/dd/yyyy') dt FROM dual UNION all SELECT 222 userid, To_Date('3/5/2010','mm/dd/yyyy') dt FROM dual UNION all ), mydates AS ( SELECT To_Date('7/31/2010','mm/dd/yyyy') dt1, To_Date('8/4/2010','mm/dd/yyyy') dt2 FROM dual UNION ALL SELECT To_Date('2/28/2010','mm/dd/yyyy') dt1, To_Date('3/5/2010','mm/dd/yyyy') dt2 FROM dual )
Basically, I join two tables, take dt from table1 and look into mydates. If the data match then display dt and DM2.DT DT2 7/31/2010 8/04/2010 8/01/2010 8/01/2010 8/02/2010 8/02/2010 8/03/2010 8/03/2010 8/04/2010 8/04/2010 8/05/2010 8/05/2010 2/28/2010 3/5/2010 3/5/2010 3/5/2010
If the date in table1 does not match date in t1d in mydates, then display the data but dt and DM2 there same date.
for example,.
7/31 in table1 is 7/31 in mydates so I show 7/31 dt and DM2 as 8/4(from mydates).
now 8/01 does not match all lines in my dates so dt should be 8/01 and T2D should be 8/01. same logic applies to the other lines
can someone write a query that gives the above result? Thank youHello
If you want all lines of table1 (attached to mydates when this is possible, but even when there is no match) then use an outer join:
SELECT t.dt , NVL (m.dt2, t.dt) AS dt2 FROM table1 t LEFT OUTER JOIN mydates m ON t.dt = m.dt1 ORDER BY t.dt ;
-
Is mapping dimension AWM - possible to load the data in two tables of entry?
Hi all
I have two tables ProductFamily (parent level) and products (child level).
I want to load a dimension of those tables where the parent-child relationships are maintained (I use AWM).
I created a map with these two entry tables, but the loaded data has no relationship.
So, how do I do that? Is it possible to load dimensions where different levels get data from multiple tables?
Is any type of Carpenter available in AWM?
Thank you
------------------------
A few Notes:
-I don't want to use OWB here that my data are clean
-In AWM, when I loaded the data in a single view that contains two tables of input data, it worked fine. But it's my worst case option.You must use Dimension option in snowflake in the mapping screen of size for the Product Dimension (as opposed to the default style mapping - star schema dimension).
This will modify map entries to include a separate parent for each level of hierarchy level / that is to say, for each level of hierarchy / (unless a higher level of the hierarchy), you must specify the parent level key in addition to the key current level, code/name/description/other attributes etc.
You can make the mapping or... use the icons at the top of the map screen.
mode drag/drop by dragging the relational column on dimension - level/hierarchy/attribute model
-or-
the table expression mapping mode that gives the same effect... by dragging a column on an attribute defined in the. . the format of
. HTH
ShankarNote1: Complete the mapping of a sudden... B & w switching mapping modes cause the mappings to reset.
NOTE2: assumes that your data are correct foreign key table parent level: ProductFamily exists in the child level table: products. -
How to create a select statement to the data in two tables?
Hi allTable 1
ID YEAR
758 2013
Table 2
ID YEAR
758 2014
I want to create some that translates into two lines: function that does this?
ID YEAR
758 2014
758 2013
Thank you, best regards.
Hello
Perhaps a select * from table1 UNION ALL select * from table2 will help you.
concerning
Kay -
I have the data into two table with the structure of similar column, I want to loop through the data in these two tables
based on some condition and runtime that I want to put the query in loop for example, the example is given, please help me
create table ab (a number, b varchar2 (20));
Insert into ab
Select rownum, rownum. "" sample "
of the double
connect by level < = 10
create table bc (a number, b varchar2 (20));
Insert into BC.
Select rownum + 1, rownum + 1 | "" sample "
of the double
connect by level < = 10
declare
l_statement varchar2 (2000);
Boolean bool;
Start
bool: = true;
If it is true, then
l_statement: =' select * ab ';
on the other
l_statement: =' select * from bc';
end if
I'm in execute immediate l_statement - something like that, but I don't know
loop
dbms_output.put_line (i.a);
end loop;
end;
Something like that, but this isn't a peace of the code work.
Try this and adapt according to your needs:
declare
l_statement varchar2 (2000);
c SYS_REFCURSOR;
l_a number;
l_b varchar2 (20);
Boolean bool;
Start
bool: = true;
If it is true, then
l_statement: = "select a, b, AB;
on the other
l_statement: = "select a, b from bc;
end if;
--
Open c for l_statement;
--
loop
extract the c in l_a, l_b;
When the output c % notfound;
dbms_output.put_line (l_a |') -' || l_b);
end loop;
close c;
end;
/
-
Delete the data in partitioned tables
Hello
Oracle 11.2.0.3.0 version, running on Linux Enterprise.
I need to remove all the data from two tables (several 100 million lines each) that are partitioned.
(1) table 1 is a partition table have varied to a DATE column
(2) Table2 is a partition of reference table; partitioning is referenced on a relationship of foreign key to Table1 (column: key Table1.Primary)
As I have no need for data, but want to keep the structure of the table, I would ideally like to delete partitions at the same time that the deletion of the data, so that the 2 tables partitioned and empty.
Additionally, Table1 has some partitioned index I would be rebuilt as an index unpartitioned (given that Table1 will be empty).
I thought I would start by removing all partitions of Table1 (via "ALTER TABLE DROP PARTITION nom_partition Table1"), but when the script came to the last partition, I got this error message:
ORA-14083: cannot delete the only one partition of a partitioned table
ORA-06512: at "SYS." DROP_PARTITIONS', line 46
If someone could advise as to the best approach to what I want to achieve with regard to the two tables? Two tables down and recreate them then without partitions would be the easiest way?
Thanks in advance for any guidance.
If someone could advise as to the best approach to what I want to achieve with regard to the two tables? Two tables down and recreate them then without partitions would be the easiest way?
Yes - delete the tables and re-create them.
As says the exception that you cannot delete the last partition. A table is partitioned either or it is not.
There was no interest at all to use DBMS_REDEFINITION to redefine tables because you do not want the data anyway.
-
Select all dates between two fields txt. How?
In a slider form 6i, I need to select all dates between two dates provided. I have two fields text Fld1 and Chp2 with the data type date. There is no table behind the two fields.
For example
': FLD1: = MARCH 1, 2013;
': CHP2: = MARCH 10, 2013;
Now I have to choose all dates between 01-mar-2013 and 2013-mar-10 '. How to do?Gul says:
In a slider form 6i, I need to select all dates between two dates provided. I have two fields text Fld1 and Chp2 with the data type date. There is no table behind the two fields.
For example
': FLD1: = MARCH 1, 2013;
': CHP2: = MARCH 10, 2013;Now I have to choose all dates between 01-mar-2013 and 2013-mar-10 '. How to do?
As'salamualikum Gul
Try this
SELECT TO_DATE('01-MAR-2013', 'DD-MON-RRRR') - 1 + rownum AS d FROM ALL_OBJECTS WHERE TO_DATE('01-MAR-2013', 'DD-MON-RRRR') - 1 + rownum BETWEEN TO_DATE('01-MAR-2013', 'DD-MON-RRRR') AND TO_DATE('10-MAR-2013', 'DD-MON-RRRR')
Hope this helps
-
concatenate the data in 2 tables in a third table as well as in CONCATENATE strings
Hello. as the title says, I wish to only concatenate the data in 2 tables in a similar third table that concatenate strings don't. All tables should be 1 d. For example, suppose that there is 1 table with the following: 1. 2; 3; 4 and table 2 with:; b; c; d. I would like a table 3 either 1 a, 2 b, 3 c, 4 d. Now this could be done easily with above mentioned concatenate strings, then table construction. but table 1 and 2 have something like 150 items. Rather painful. Any ideas?
Hold arrays of two strings in a loop for example, concatentate the strings inside the loop and run the result réécrirait array3.
Autoindexing manages table manipulations.
MIke...
-
SQL Loader loading data into two Tables using a single CSV file
Dear all,
I have a requirement where in I need to load the data into 2 tables using a simple csv file.
So I wrote the following control file. But it loads only the first table and also there nothing in the debug log file.
Please suggest how to achieve this.
Examples of data
Source_system_code,Record_type,Source_System_Vendor_number,$vendor_name,Vendor_site_code,Address_line1,Address_line2,Address_line3
Victor, New, Ven001, Vinay, Vin001, abc, def, xyz
Control file script
================
OPTIONS (errors = 0, skip = 1)
load data
replace
in the table1 table:
fields ended by ',' optionally surrounded "" "
(
Char Source_system_code (1) POSITION "ltrim (rtrim (:Source_system_code)),"
Record_type tank "ltrim (rtrim (:Record_type)),"
Source_System_Vendor_number tank "ltrim (rtrim (:Source_System_Vendor_number)),"
$vendor_name tank "ltrim (rtrim (:Vendor_name)),"
)
in the Table2 table
1 = 1
fields ended by ',' optionally surrounded "" "
(
$vendor_name tank "ltrim (rtrim (:Vendor_name)),"
Vendor_site_code tank "ltrim (rtrim (:Vendor_site_code)),"
Address_line1 tank "ltrim (rtrim (:Address_line1)),"
Address_line2 tank "ltrim (rtrim (:Address_line2)),"
Address_line3 tank "ltrim (rtrim (:Address_line3)).
)the problem here is loading into a table, only the first. (Table 1)
Please guide me.
Thank you
Kumar
When you do not provide a starting position for the first field in table2, it starts with the following after a last referenced in table1 field, then it starts with vendor_site_code, instead of $vendor_name. So what you need to do instead, is specify position (1) to the first field in table2 and use the fields to fill. In addition, he dislikes when 1 = 1, and he didn't need anyway. See the example including the corrected below control file.
Scott@orcl12c > test.dat TYPE of HOST
Source_system_code, Record_type, Source_System_Vendor_number, $vendor_name, Vendor_site_code, Address_line1, Address_line2, Address_line3
Victor, New, Ven001, Vinay, Vin001, abc, def, xyz
Scott@orcl12c > test.ctl TYPE of HOST
OPTIONS (errors = 0, skip = 1)
load data
replace
in the table1 table:
fields ended by ',' optionally surrounded "" "
(
Char Source_system_code (1) POSITION "ltrim (rtrim (:Source_system_code)),"
Record_type tank "ltrim (rtrim (:Record_type)),"
Source_System_Vendor_number tank "ltrim (rtrim (:Source_System_Vendor_number)),"
$vendor_name tank "ltrim (rtrim (:Vendor_name)).
)
in the Table2 table
fields ended by ',' optionally surrounded "" "
(
source_system_code FILL (1) POSITION.
record_type FILLING,
source_system_vendor_number FILLING,
$vendor_name tank "ltrim (rtrim (:Vendor_name)),"
Vendor_site_code tank "ltrim (rtrim (:Vendor_site_code)),"
Address_line1 tank "ltrim (rtrim (:Address_line1)),"
Address_line2 tank "ltrim (rtrim (:Address_line2)),"
Address_line3 tank "ltrim (rtrim (:Address_line3)).
)
Scott@orcl12c > CREATE TABLE table1:
2 (Source_system_code VARCHAR2 (13),)
3 Record_type VARCHAR2 (11),
4 Source_System_Vendor_number VARCHAR2 (27),
5 $vendor_name VARCHAR2 (11))
6.
Table created.
Scott@orcl12c > CREATE TABLE table2
2 ($vendor_name VARCHAR2 (11),)
3 Vendor_site_code VARCHAR2 (16).
4 Address_line1 VARCHAR2 (13),
5 Address_line2 VARCHAR2 (13),
Address_line3 6 VARCHAR2 (13))
7.
Table created.
Scott@orcl12c > HOST SQLLDR scott/tiger CONTROL = test.ctl DATA = test.dat LOG = test.log
SQL * Loader: release 12.1.0.1.0 - Production on Thu Mar 26 01:43:30 2015
Copyright (c) 1982, 2013, Oracle and/or its affiliates. All rights reserved.
Path used: classics
Commit the point reached - the number of logical records 1
TABLE1 table:
1 row loaded successfully.
Table TABLE2:
1 row loaded successfully.
Check the log file:
test.log
For more information on the charge.
Scott@orcl12c > SELECT * FROM table1
2.
RECORD_TYPE SOURCE_SYSTEM_VENDOR_NUMBER $VENDOR_NAME SOURCE_SYSTEM
------------- ----------- --------------------------- -----------
Victor Ven001 new Vinay
1 selected line.
Scott@orcl12c > SELECT * FROM table2
2.
$VENDOR_NAME VENDOR_SITE_CODE ADDRESS_LINE1 ADDRESS_LINE2 ADDRESS_LINE3
----------- ---------------- ------------- ------------- -------------
Vinay Vin001 abc def xyz
1 selected line.
Scott@orcl12c >
-
Select the column in a table that is defined in the select previous in the statement
Hello
I want to write a procedure that selects all the data in a table has then records them in the text file. I tested on table hr.countries.
My code is like this:
echo off newpage 0 space 0 pagesize 0 feed head off trimspool check out serveroutput on the value
coil countries.txt
define dtable = COUNTRY;
declare
col_num NUMBER;
no_lig NUMBER;
line VARCHAR2 (100);
Col VARCHAR2 (100);
Start
Select count (COLUMN_ID) in the col_num USER_TAB_COLUMNS WHERE table_name = '& dtable';
Select count (*) in no_lig of & dtable;
because me in 1.row_num
loop
1.col_num j
loop
Select column_name from col FROM USER_TAB_COLUMNS WHERE table_name = '& dtable' and column_id = j;
Select the pass in the row (select col, rownum: nurse of (select col from & dtable)) where rn = i;
IF (j! = col_num) THEN
DBMS_OUTPUT. PUT(Row ||) ', ');
ON THE OTHER
DBMS_OUTPUT. PUT (Row);
END IF;
end loop;
DBMS_OUTPUT. NEW_LINE;
end loop;
end;
/
spool off
I have had no error, but the result is like this:
COUNTRY_ID, COUNTRY_NAME, REGION_ID
COUNTRY_ID, COUNTRY_NAME, REGION_ID
COUNTRY_ID, COUNTRY_NAME, REGION_ID
.. and so on for the whole table.
I want to have results with data not only the names of columns. No idea what is the problem? I thought that select col online would do the thing, but the line is identical to the col variable...
Thank you
Honza
Set serveroutput on;
define dtable = COUNTRY;
declare
col_num NUMBER;
no_lig NUMBER;
line VARCHAR2 (100);
Col VARCHAR2 (100);
Start
Select count (COLUMN_ID) in the col_num USER_TAB_COLUMNS WHERE table_name = '& dtable;
Select count (*) in the no_lig argument of &dtable;
because me in 1.row_num
loop
1.col_num j
loop
Select column_name from col FROM USER_TAB_COLUMNS WHERE table_name = '& dtable' and column_id = j;
run immediately 'select'. Col | "from (select ' |) Col |', rownum: nurse from (select ' |) Col |' of & dtable)) where rn =' | I have
Online;
IF (j! = col_num) THEN
DBMS_OUTPUT. PUT(Row ||) ', ');
ON THE OTHER
DBMS_OUTPUT. PUT (Row);
END IF;
end loop;
DBMS_OUTPUT. NEW_LINE;
end loop;
end;
/
Output
anonymous block filled
AR, Argentina, 2
To, Australia, 3
BEING, Belgium, 1
BR, Brazil, 2
CA, Canada, 2
CH, Switzerland, 1
CN, China, 3
OF (Germany), 1
DK, Denmark, 1
For example, Egypt, 4
FR, France, 1
HE, Israel, 4
IN, India, 3
IT, Italy, 1
JP, Japan, 3
KW, Kuwait, 4
ML, Malaysia, 3
MX, Mexico, 2
NG, Nigeria, 4
NL, Netherlands, 1
SG, Singapore, 3
UK, United Kingdom, 1
WE, United States of America, 2
ZM Zambia, 4
ZW, Zimbabwe, 4
-
Size of the data in a table and the size of the table
I am trying to determine the size of the data in a table and also the overall table size. I use the following query:
SELECT BOTTOM (a.owner) as owner,
LOWER (a.table_name) AS table_name,
a.tablespace_name,
a.Num_Rows,
ROUND ((a.blocks * 8 / 1024)) AS size_mb,
a.Blocks,
a.Blocks * 8 Blocks_Kilo_Byte.
a.PCT_FREE,
a.compression,
a.Logging,
b.bytes / 1024 / 1024
From all_tables a, dba_segments b
WHERE the a.owner AS SUPERIOR ("USER_TEST")
AND a.table_name = "X_TEST_TABLE."
AND b.segment_name = a.table_name
AND b.owner = a.owner
ORDER BY 1, 2;
Is this the right way to go about finding the size of the data in a table? If this isn't the case, please give your suggestions.
BTW, this in a 10g version.You probably want to use the DBMS_SPACE package. In particular, the procedures SPACE_USAGE and UNUSED_SPACE to get an accurate account of the use of space in a table. Your application may give you a relatively accurate estimate if the optimizer on your table's statistics are reasonably accurate estimates. But there is no guarantee that the optimizer statistics are accurate.
If you want just an approximate answer and you're comfortable that your statistics are accurate, this query may be close enough. If you want a specific response, however, use the DBMS_SPACE package.
Justin
-
Inventory of the data of all Tables in a database
Hello
We do the analysis of the existing data base (Oracle 10 g) and I want to prepare an inventory of the data of all tables in a database that is
1. total number of records in a table
2. total number of records that have null values in a column
3. total number of standalone tables IE have no connection with other tables
etc...
Please let me know if there are tools or query that can do these tasks.
Thank you and best regards,
Lokeshselect owner "Owner", table_name "Table_Name", column_name "Column_Name", initcap(data_type) || decode(data_type, 'CHAR', '('|| char_length ||')', 'VARCHAR', '('|| char_length ||')', 'VARCHAR2', '('|| char_length ||')', 'NCHAR', '('|| char_length ||')', 'NVARCHAR', '('|| char_length ||')', 'NVARCHAR2', '('|| char_length ||')', 'NUMBER', '('|| nvl(data_precision,data_length)|| decode(data_scale,null,null, ','||data_scale)||')', null) "Type", nullable "Nullable", decode(to_char(num_distinct), 0,'No', 'YES') "Have Data", owner sdev_link_owner, table_name sdev_link_name, 'TABLE' sdev_link_type from sys.dba_tab_columns where (:OWNER is null or instr(owner,upper(:OWNER)) > 0) and (:TABLE_NAME is null or instr(upper(table_name),upper(:TABLE_NAME)) > 0) and (:COLUMN_NAME is null or instr(upper(column_name),upper(:COLUMN_NAME)) > 0) and substr(table_name,1,4) != 'BIN$' and substr(table_name,1,3) != 'DR$' order by owner, table_name, column_id
I added a new column with an alias "get data". This new column will display "NO" is the entire column is zero and 'YES' if there is even a value not null in the column. But caution is that statistics table must be updated to get the correct results.
Thus, it may be useful to gather current statistics before executing the query.
Exec dbms_stats.gather_schema_stats or even dbms_stats.gather_database_stats.
Maybe you are looking for
-
MY keyboard is now shared and until Mid-screen instead of set and future on the background.
-
I have a laptop with mac macbook air OS X el Captain 10.11.5 and an iPhone with iOS 9.3.2,and 6 both on a wifi modem router from netgear. I can't use bluetooth or airdrop. I have paired other mobiles with bluetooth mobile tony but cannot then get iPh
-
Unable to access iPhoto Library in iMovie!
Since I upgraded my mac computer at the El Captian, I am not able to access the iPhoto library in iMovie where you usually go to import photos after clicking on the camera icon. My iMovie is a ' 08 version. When I clicn the camera icon to import phot
-
Song from an Album of her own 50th Album
If I'm honest it's a compilation with two discs of 25 CD. The 25th song on the second CD is in her own album with the same exact information. Is it all just because iTunes cannot contain 50 songs in 1 album? If this is not the case, is it possible to
-
Need assistance, transfer of files to a flash drive for backup.
I need to delete my aol files to a flash drive for storage. I tried to find the path on my pc but cannot locate. I need to know if it is possible? Also, I need to know if I'll be able to open the mails from the flash drive after I download, it is pos