How to check the existence of database table?
I want to check if a certain database table exists, if so run the code / display message etc.not if the table contains data or not, but if it's in the database.
Any idea?
Thank you!
find a way to query the system tables, assuming that you have permission to do so. The details are specific to db.
Tags: ColdFusion
Similar Questions
-
How to check the existence of a value in a table before copying the data?
Experts,
I have a requirement in which I need to copy data (4 columns) table A to table B (4 columns)
Table A (entry)
PART_ID PART_NAME PART_OPT_CD ENGG_OPT_CD
1 "AAA" 10 100
2 'BBB' 20 200
3 'CCC' 30 300
4 'DDD' 40 400
5 'EEE' 50 500
I have a table named OPTIONS with a single column. This is a table of reference of business which has the master list of option codes.
OPT_CD
10
20
30
50
60
100
200
400
500
I need to copy Table A to Table B, but in doing so, I need to check the values of columns 3 and 4 in the OPTIONS array.
If there is copy the folder B. Otherwise error in the log in a file/table and continue with the next copy
TABLE B (exit)
PART_ID PART_NAME PART_OPT_CD ENGG_OPT_CD
1 "AAA" 10 100
2 'BBB' 20 200
5 'EEE' 50 500
WARNING file or a table should have the details below.
300 ENGG_OPT_CD does not exist in the table OPTIONS, so part_id 3 have not migrated
40 PART_OPT_CD does not exist in the table OPTIONS, then part_id 4 have not migrated
Company don't bother about the format of error, we need this information to correct the OPT_CD in the OPTIONS table.
Can anyone suggest a better way to do this. Thank you for your help in advanceHello
Its very similar to your previous post.
Re: PL/SQL help
The only difference being that you have to outer join to your superimposed master table, since your search in two columns values occur only in a single column on your Master table.Something like that;
create table a (part_id number, part_name varchar2(10),part_opt_cd number,engg_opt_cd number); insert into a (select 1 Part_ID, 'AAA' Part_Name, 10 Part_Opt_CD, 100 ENGG_Opt_CD from dual union all select 2, 'BBB', 20, 200 from dual union all select 3, 'CCC', 30, 300 from dual union all select 4, 'DDD', 40, 400 from dual union all select 5, 'EEE', 50, 500 from dual union all select 6, 'FFF', 60, 500 from dual ) / create table b (part_id number, part_name varchar2(10),part_opt_cd number,engg_opt_cd number); insert into b (select 1 Part_ID, 'AAA' Part_Name, 10 Part_Opt_CD, 100 ENGG_Opt_CD from dual union all select 2, 'BBB', 20, 200 from dual union all select 5, 'EEE', 50, 500 from dual ) / Create table master (OPT_CD number); insert into master ( select 10 opt_cd from dual union all select 20 from dual union all select 30 from dual union all select 50 from dual union all select 60 from dual union all select 100 from dual union all select 200 from dual union all select 400 from dual union all select 500 from dual ) / create table log_msg (msg varchar2(100) ,t timestamp default current_timestamp) / SQL> insert all 2 when Master1_ID is not null and 3 Master2_ID is not null then 4 into b (Part_ID, Part_Name, Part_Opt_CD, ENGG_Opt_CD) 5 values (Part_ID, Part_Name, Part_Opt_CD, ENGG_Opt_CD) 6 when Master1_ID is null or 7 Master2_ID is null then 8 into log_msg (msg) values (Part_Opt_CD || ' ' || ENGG_Opt_CD || ' does not exist on the Master table') 9 select m1.Opt_CD as Master1_ID 10 ,m2.Opt_CD as master2_ID 11 ,a.Part_ID as Part_ID 12 ,a.Part_Name as Part_Name 13 ,a.Part_Opt_CD as Part_Opt_CD 14 ,a.ENGG_Opt_CD as ENGG_Opt_CD 15 from ( 16 select a.Part_ID, a.Part_Name, a.Part_Opt_CD, a.ENGG_Opt_CD 17 from a 18 left outer join b on a.Part_ID = b.Part_ID 19 where b.Part_ID is null 20 ) a 21 left outer join master m1 on a.Part_Opt_CD = m1.Opt_CD 22 left outer join master m2 on a.ENGG_Opt_CD = m2.Opt_CD 23 / 3 rows created. SQL> select * from log_msg; MSG T ------------------------------------------- ------------------------- 40 400 does not exist on the Master table 05-OCT-11 09.44.17.621000 30 300 does not exist on the Master table 05-OCT-11 09.44.17.621000 SQL> select * from b; PART_ID PART_NAME PART_OPT_CD ENGG_OPT_CD ---------- ---------- ----------- ----------- 1 AAA 10 100 2 BBB 20 200 5 EEE 50 500 6 FFF 60 500
Note, I have included an additional line in table A in order to prove that the INSERTION will occur in table B. Errors, as you can see have been inserted in the table LOG_MSG.
Published by: bluefrog October 5, 2011 09:48
-
How to get the use of database tables/columns in the table of edge/analysis?
Hi allAnyone has an idea on how to get the tables in DB/colomns usaged in edge/analysis table in OBIEE 11 G?
Thanks in advance!
Anne
You can try to generate a report of Catalog Manager for analysis / SA want to create the line and your RPD you can go to utilities > documentation of the repository and get the domain you want to and get all the mappings in Excel format.
I hope this helps.
SVS
-
How to check the version of database Oracle
Hello
How can I check what type of database is used and what version?
Can someone help me find out?You can try:
SELECT * FROM V$VERSION
or
SELECT version FROM V$INSTANCE
or
BEGIN DBMS_OUTPUT.PUT_LINE(DBMS_DB_VERSION.VERSION || '.' || DBMS_DB_VERSION.RELEASE); END;
-
How to check the number of databases, I have
How to check how much data I have on my each server with address name and path of the House without using OEM? also need to check how much is on the rise and how much is down?
Kind regards
NirajWindows
=======
Check the name of the Windows Service.on the start menu, you can find run ---> type services.msc
It will be something like:
OracleServiceDB10G
OracleServiceORCL
-
How to check the existence of field in a chain at the level of the header?
Hello
I have a bunch of fields on my_form, just for example here in this announcement I'm on U.S. State names, say for example.I have 3 domains, their names are as below
1) NY,
2) CA,
(3) TX
I placed a hidden his name, a text field is FGL (I mean, the gray field list), uses this GFL for my purpose of programming
Since the back-end (in our case, its an ERP - SAP) am filling/filling this field GFL, say for example... its data looks like, CA TX (I mean, am concatenating the names of State with a separation of a space)
(FYI... I already have some piece of JS in my_form INITIALIZATION and for certain other purposes docReady event)
Now my requirement is as below,
(1) LOOP all objects domain (here they are like state names) of my_form, then check if their name (NY) existing data of GFL... If exisitng (in our case, its not existing) pls shaded with readOnly... If not existing
(in our case, its not existing) pass the coloring and readOnly, go to the next loop / iteration / state / field
Actually, I can achieve my requirement by putting the JS in initialization event each object field as mmee below, (but I have about 200 fields in my_form, that's why I want to put all the field objects of my_form in one piece of code at the level of the header in a generic way in loop),
var myStateName = / NY /;
var returnValue = GFL.search (myStateName);
If (returnValue! = - 1) {;} / / This state/field/object is found in the list of fields of gray, so dimmed with readOnly
this.ui.oneOfChild.border.fill.color.value = "192,192,192."
This.Access = "readOnly";
};For certain other requirements, one of the experts provided below JS in these forums, as below
function findNodes (vNode) {}
If (vNode.className = 'field') {}
If (vNode.isPropertySpecified ("name") = true) {}
If (.search(/_U$/g) vNode.getAttribute ('name')! ==-1) {}
/ / Script to run, when a match is found
...
}
}
}
for (var i = 0; i < vNode.nodes.length; i += 1) {}
findNodes (vNode.nodes.item (i));
}
}
findNodes (xfa.form);
In fact, I tried to change the JS above according to my needs, but its does not work, please provide me with the correct JS according to my requirement.
Thank you
Try this:
function findNodes (vNode) {}
If (vNode.className = 'field') {}
If (vNode.isPropertySpecified ("name") = true) {}
var myStateName = new RegExp (vNode.name);
var returnValue = GFL.search (myStateName);
If (returnValue! =-1) {}
this.ui.oneOfChild.border.fill.color.value = "192,192,192";
This.Access = "ReadOnly";
}
else {}
this.ui.oneOfChild.border.fill.color.value="255,255,255";//whatever color is free access
This.Access = "Open";
}
}
}
for (var a = 0;<>
findNodes (vNode.nodes.item (a));
}
}
findNodes (xfa.form);
Kyle
-
checking the existence of a table - MySQL
I use MySQL and I just want to see if a table exists so that I can select data from it or if it does not exist, I want to shoot the same fields of a table I already know exists.
Any help would be greatly appreciated.
Thank youQuote:
Posted by: Alexandre
using MySQL
SELECT count (*) did testValue
FROM information_schema.tables
WHERE table_schema = 'the_database_name. '
AND table_name = 'your_table_name '.
SELECT *.
Of your_table_name
SELECT *.
Of other_table_name
Thanks Alexandre! This works perfectly. I do not administer the ColdFusion server, so I hope that administrators manage security issues.
-
How to check the locks in the database
Hello
oracleDatabase version: 11 GR 2
OS: Solaris
How to check the locks on database objects .it can be any lock?
None Select sql query to check the levlel of objects of database locks? what basis locks occur?
Please explain on the locks or share notes MOS?
Rgds,
Sam.Check below sql.
Select s1.username. '@' || S1.machine
|| ' (SID =' | s1.sid | block him ') '
|| S2. UserName | '@' || S2.machine | ' (SID =' | s2.sid |) ') ' AS blocking_status
v $ lock l1, v$ session s1, v$ lock l2, s2 of v$ session
where s1.sid = l1.sid and s2.sid = l2.sid
and l1. BLOCK = 1 and l2.request > 0
and l1.id1 = l2.id1
and l2.id2 = l2.id2;http://psoug.org/snippet/locks-view-locked-Objects_866.htm
http://www.DBA-Oracle.com/t_locked_rows_user_locks.htm -
How to improve the custom rule by checking the existence of the role with INSERT permission?
Hello
following a custom rule to check the existence of some columns of audit - how can I improve this rule only to run for tables where there is a role with privileges to INSERT?
Günter cordially
function checkAudit (table) {}
inserted_by = false;
inserted_at = false;
ruleMessage ="";
tNom = table.getName ();
If (tname.indexOf ('_DWH_') == - 1).
{
columns = table.getElements ();
l = columns.length;
for (var c = 0; c < l; c ++)
{
CNAME = columns [c] .getName ();
If (cname == "INSERTED_AT") {inserted_at = true}
If (cname == "INSERTED_BY") {inserted_by = true}
}
If (! inserted_at) ruleMessage = ruleMessage + not 'INSERTED_AT ';
If (! inserted_by) ruleMessage = ruleMessage + not 'INSERTED_BY ';
}
If (ruleMessage! = "")
Returns false;
on the other
Returns true;
}
checkAudit (table);
Hi Gunter,
the function to check if the column of table a insert privilege for role is less.
It is possible insert are defined in table instead of the column - that does not check the function below.
Philippe
function hasColumnWithInsertForRole(table){ sd = table.getRelationalModel().getStorageDesign(); tp = sd.getStorageObject(table.getObjectID()); if(tp!=null){ roles = sd.getRoleSet().toArray(); for(var i=0;i
-1){ return true; } } } return false; } hasColumnWithInsertForRole(table); -
How to check the status of the statistics on a table?
Hello
I started the statistics collection on a few large tables in my database.
How to check the status of statistics about a table? Are there views of data dictionary or tables to monitor the progress of the collection of statistics.
Regds,
MalikaHi all
You can check with this little script.
It lists details of sid for long as running session
When he started
What last update
How long still to the left
"ACTIVE/INACTIVE" session state etc.---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-Author: James Syed_
-Script_name: sid_long_ops.sql
-Description: list details of sid for long running the session as when it began when the last update how long still to the left.fixed lines 200
Neck LESS to a25Select
a.SID,
a.Serial #.
b.Status,
a.opname,
TO_CHAR (a.START_TIME,' DD-me-AAAA HH24:mi:ss) START_TIME,
TO_CHAR (a.LAST_UPDATE_TIME,' DD-me-AAAA HH24:mi:ss) LAST_UPDATE_TIME,.
a.time_remaining as 'time remaining dry. "
a.time_remaining/60 as "Min remaining time."
a.time_remaining/60/60 as 'remaining time in HR.
V $ session_longops a, v$ session b
where = select a.sid
a.sid = & sid
And time_remaining > 0;----------------------------------------------------------------------------------------------------------------------------------------------------------------
The sample output:
--------------------SQL > @sid_long_ops
Enter the SID value: 474
13 old: a.sid = & sid
13 News: and a.sid = 474SID, SERIAL # STATUS START_TIME LAST_UPDATE_TIME remaining time LESS dry time remaining minutes remaining HR time
--------------------------------
474 2033 ACTIVE collection schema statistics June 6, 2012 20:10:49 June 7, 2012 01:35:24 572 9.53333333.158888889Thank you & best regards
Syed James.
Oracle Apps DBA
Mobile: + 91 9966270072
E-mail: [email protected] -
How to check the amount/number of issued on the database DDL operations
Hello
Can someone please clear some doubts.
1. How can we check the number of DDL operations on the database
2. how we check the amount of growth in the size of the database.
3. How can we check the growth of a single table.
Concerning
AmithSelect startup_time "Startup."
MySQL 'Transactions. "
/Decode (value) sum (Sum (trunc(sysdate-STARTUP_TIME)), 0.1, Sum (trunc(sysdate-STARTUP_TIME))) "Avg per day."
/Decode (value) sum (Sum (trunc(sysdate-STARTUP_TIME)), 0.1, Sum (trunc(sysdate-STARTUP_TIME))) / 24 ' Avg / hour. "
/Decode (value) sum (Sum (trunc(sysdate-STARTUP_TIME)), 0.1, Sum (trunc(sysdate-STARTUP_TIME))) / 1440 "Avg / min.
v $ sysstat, instance $v
WHERE name in (a "user is committed," restores user)
Startup_time group; -
How can I check the version of database?
How can I check the version of database if it uses inside my PL/SQL block?
Use sql in your pl/sql block.
Select * from version £ v
-
How to check the value of the space of the tablespaces and tables when errors occur?
Hi Experts,
For example, lets say we get ORA-01653: unable to extend table of error. How to check the size of the table and a tablespace? And how understanding is full?
Thanks for your help
Hello
Select df.tablespace_name "Tablespace"
totalusedspace 'Used MB',
(df.totalspace - tu.totalusedspace) "MB free.
DF. TotalSpace 'Total MB. "
round (100 * ((df.totalspace-tu.totalusedspace) / df.totalspace))
"PCT free."
Of
(select nom_tablespace,
Round (Sum (bytes) / 1048576) TotalSpace
from dba_data_files
Group by tablespace_name) df,.
(select round (sum (bytes) /(1024*1024)) totalusedspace, nom_tablespace)
from dba_segments
you group by tablespace_name)
where df.tablespace_name = tu.tablespace_name
and df.tablespace_name = "
"; For example, lets say we get ORA-01653: unable to extend table of error. How to check the size of the table and a tablespace? And how understanding is full?
Is to say clearly to the question (you can let us know what you have understood so we can fix)
[oracle@machine1 ~] $01653 oerr ora
01653, 00000, "impossible to extend %s.%s table by %s in %s tablespace»
* Cause: Failed to allocate a certain measure the required number of blocks for
a segment of the table in the specified tablespace.
* Action: Use ALTER TABLESPACE ADD DATAFILE statement to add one or more
storage of files indicate.
-Thank you
Pavan Kumar N
-
How to check the CPU usage in the database
How to check the CPU usage?
in Linux and database level
Hello
under Linux, you can use mpstat command, for example:
[oracle@vSLLGM132 ~] $ mpstat Pei ALL 2 10
Linux 2.6.32 - 300.10.1.el5uek (vSLLGM132) 23.11.201414:27:08 CPU user nice sys % iowait % irq % sweet % fly % idle intr/s
14:27:10 all 1.00 8.50 9.00 0.00 0.00 0.50 0.00 1423,50 81.00
14:27:10 0 1.00 8.50 9.00 0.00 0.00 0.50 0.00 81.00 26.50CPU utilization tracking can be done with the command SAR u.
.At the database level: data dictionary views: v$ sysstat, v$ iostat, V$ SYSMETRIC_HISTORY.
Read the MOS Notes:
Diagnose hardware base caused by Performance issues (Doc ID 148176.1)
Troubleshooting: The use of high processor (Doc ID 164768.1)
Concerning
Borys
-
How to check the table of organization
Hi all
How can we check the Organization of a table and more knowing that at the time of the creation of the TABLE, as we do for the external ORGANIZATION EXTERNAL tables.
Thank youuser13332773 wrote:
Hi allHow can we check the Organization of a table and more knowing that at the time of the creation of the TABLE, as we do for the external ORGANIZATION EXTERNAL tables.
Thank you
select * from dba_tables where iot_type = 'IOT'
Maybe you are looking for
-
Satellite M40 - 142, stereo audio input
I can 'stereo' record through the microphone in Satellite M40 - 142?It is possible to have a line-input/output stereo or mono only?
-
Pavilion g7-1077nr: HP PAVILION g7-1077nr forgotten power on password
Hi, I have not used this laptop for a while and I forgot my password on. A way to recover or reset it? Thanks in advance.
-
HP CDDVDW TS - T633P SCSI CdRom - cannot read SOME DVD
PC is a Touchsmart 600-1000 t, Windows 7 DVD Player cannot read some DVD. Completed all the 8 steps in "Drive cannot read disks (Windows 7)" on the HP site. A ran HP "Hardware Diagnostic Tools" (linear CD search Test"and it passes on some DVDs and
-
Switchable Graphics do not appear
Hello whene I do a right click on the desktop backgroundGraphics properties appear and switchable graphics are not displayed? I have 2graphic card! on dv6 i7 AMD - HD7400m -Intel HD 3000 I already intalled last driver amd! Note: the bios in graphica
-
Set up my new Imac with a partition for Windows 7 a couple of days. The Imac has had a number of questions and today Apple Support have advised me to return it and get a replacement. I am able to delete the copy of Windows via bootstrap, but I have