Need to retrieve the names of columns with PK
Hi all
guys I need to get two columns (PK information and secondly with the column name) for the table. I see that's not so easy with Oracle ;(
I have this for now:
SELECT all_tab_cols.column_name,user_constraints.constraint_type FROM all_tab_cols, user_cons_columns, user_constraints,user_ind_columns, user_indexes WHERE all_tab_cols.column_name = user_cons_columns.column_name (+) AND all_tab_cols.table_name = user_cons_columns.table_name (+) AND user_cons_columns.constraint_name = user_constraints.constraint_name (+) AND user_constraints.constraint_type (+) = 'P' AND user_ind_columns.column_name (+) = all_tab_cols.column_name AND user_ind_columns.table_name (+) = all_tab_cols.table_name AND user_indexes.uniqueness (+) = 'UNIQUE' AND user_indexes.index_name (+) = user_ind_columns.index_name AND all_tab_cols.table_name = 'MYTABLE'
but, if KP is then take result duplicate me lines and there is not a simpler way? just need to list all columns of the table with information about the PK
SELECT acc.column_name, ac.constraint_name FROM all_constraints ac, all_cons_columns acc WHERE ac.owner =acc.owner AND ac.constraint_name=acc.constraint_name AND ac.table_name =acc.table_name AND ac.constraint_type='P' AND ac.table_name = 'MY_TABLE' UNION SELECT column_name,NULL FROM all_tab_columns WHERE table_name='MY_TABLE';
Tags: Database
Similar Questions
-
Retrieve the names of columns in a table.
Hi all
I want to retrieve column names of a table "test", whose values are null
For ex:
Select * from test
give the results that
column_1, column_2, column_3, column_4
111
allows to consider the case that the table has only one record.
as a result, we will have to get column_2, column_3, column_4 and more.
I tried dynamic "run immediately" the statement and tried to extract in a single execution of immediate instruction, but I wasn't able to accomplish because of several columns.
is it possible without using a pl/sql function or procedure?Check this box:
SQL> INSERT INTO my_Test values('ABCD',NULL,NULL); 1 row created. SQL> COMMIT; Commit complete. SQL> select * from my_Test; COL1 C COL3 ---------- - ---------- ABCD SQL> declare 2 CURSOR C1 IS SELECT column_name FROM all_tab_cols WHERE table_name = 'MY_TEST'; 3 v_sql VARCHAR2(10000) := NULL; 4 my_null_col_list VARCHAR2(32767) := NULL; 5 my_cnt NUMBER := 0; 6 BEGIN 7 FOR I in C1 LOOP 8 v_sql := 'SELECT COUNT(*) FROM my_test WHERE '||I.column_name ||' IS NULL'; 9 execute immediate v_sql INTO my_cnt; 10 IF (my_cnt > 0) THEN 11 my_null_col_list := my_null_Col_list||','||I.column_name; 12 END IF; 13 END LOOP; 14 my_null_col_list := SUBSTR(my_null_col_list,2); 15 dbms_output.put_line('Columns that have null values for table my_Test are:'||my_null_col_list); 16 END; 17 / Columns that have null values for table my_Test are:COL2,COL3 PL/SQL procedure successfully completed. SQL> desc my_test; Name Null? Type ----------------------------------------- -------- ---------------------------- COL1 VARCHAR2(10) COL2 VARCHAR2(1) COL3 VARCHAR2(10) SQL>
-
How to dynamically change the names of columns LOV
Hello
I use JDeveloper 11.1.1.4
I have only one requirement, while I need to change the names of columns in the list of values dynamically.
How can I achieve it.
Please help me.
Kind regards
John.
Hello
> But I want to change the column names 'ID' and 'Name' dynamically.
Based on what? Condition? If Yes, have you tried to set the text for the label as an expression? If not based on the condition, you can also expose the VO to Java Impl and need a way to get the attribute and change its label.
Arun-
-
Is it possible, using ExtendScript, to retrieve the name of a model used in first
I have an AE Comp used in first instance. I'm looking for a way to quickly manage the names of the AE model and this model used in the first instance. The goal is to maintain naming conventions as efficiently and accurately as possible. I was wondering if there is a way, using ExtendScript (a command in a custom panel) to retrieve the name AE Comp of her in first instance.
Any projectItem with a path ending with .aep is a likely candidate.
Our next version provides iteration better the elements in a sequence; You can reach the projectItem of any clip, that should give you what you need.
-
Retrieves the name of the variable
Hello
I'm trying to change the OpenG changed? Subvi (see below) so that he will write the new value of the variable sent to 'Variant' if changed on the disk (using the following config VI). To do this, I need to somehow extract the variable name of the variable (any type) which was connected to the entrance of variant of the changed? Sub - VI by VI calling so that I can use it as a key name. Is this possible? This information is still transmitted to the Subvi?
If you use openg, there is a "Get the name of data" function that retrieves the name of the data passed in the Variant.
-
Retrieve the name of the model of the device
Hello
Is there a way to retrieve the name of the device in use? I wish I could know if the user is using a Z10, Q10 etc...
Thank you
Scott
Have you tried with HardwareInfo?
https://developer.BlackBerry.com/Cascades/reference/bb__device__hardwareinfo.html
-
How to extract the names of columns in dynamic SQL
Hi all
Is it possible to extract all the names of columns in a dynamic query?
In my case according to the user selections that my query will get changed (number of the column, column name and tables that everything can vary).
So now, is it possible to retrieve all the column names of the dynamic query generated?
I am using Oracle 11g (11.2.0.4)
Thank you
Shaz
-
Hi all
I have a requirement like the reading of the data from the DB table and put it in a location of ftp server using mediator.also file in the ftp location must be in .csv format.
I am able to get the data from the file in .csv format.
But here, my requirement is I want the data from the file with the names of columns (i.e. header information).
Can someone help me in this problem.
Thanks in advance,
Divya.
Hello
I am able to get the information to complete file with column names.
I added a code in the ftpadapter xsd file.
nxsd:version = "NXSD".
nxsd:stream = "chars".
nxsd: encoding = "US-ASCII".
nxsd:hasHeader = 'true '.
nxsd:headerLines = "1".
nxsd:headerLinesTerminatedBy = "${eol}.
nxsd:outboundHeader = "empno, ename, sal, location, status ${eol} '"
By adding the code above, I'm able to get the full file header information.
Thank you
-
Please share the Script to retrieve the name of host, HBA, HBAstatus, WWN, pathpolicy and dualpathinfo
Take a look on Re: information on the host hardware with information about the HBA drivers and nic
-
Need to change the name of the file hard
I need to change the name of the vmdk files which will get the game of football on behalf of virtual machines. Please anyone suggest me the steps to that end, the sameange the
Hello
Hope you are looking steps below.
Renaming of files in virtual machine using Cold Storage Migration
Virtual machine files can be renamed on the fly when cold Migration is initiated from the vSphere Client, only documents of the virtual machine are renowned.
To rename the files:
Log on to the VMware vSphere Client.
Locate the virtual machine in your inventory to the host.
Right-click the virtual machine, and then click Rename.
Change the name of the virtual machine as required.
Perform a cold migration to a new virtual machine data store.
For more information, see:
For ESXi/ESX 4.x, see Migration cold in the Guide of Administration of vSphere Datacenter.
For ESXi/ESX 3.5, see Migration cold in basic management Guide.
When the migration is complete, the files of the virtual machine, the name of the virtual machine configured in step 4.
Note: If a virtual directory already exists on the data store with the same name, then the virtual target machine is placed in a new directory with annexed _1.
-
ORE: the names of columns not valid cost.matrix
I'm trying to use the method odmDT with application costs customized as follows:
> dt.mod = ore.odmDT (default ~.,credit_train,max.depth=20,cost.matrix=matrix(c(0,1,4,0),nrow=2)
but I get the error:
Error in ore.odmDT (default ~., credit_train, max.depth = 20, cost.matrix = error_cost):
ORE: the names of columns not valid cost.matrix
I can't find any documentation anywhere on how exactly this cost matrix must be specified.
Any help would be appreciated
The value for cost.matrix currently requires a data structure object. The following examples using the NARROW data successfully pass a frame of data for the value of cost.matrix:
R > NARROW.costs.gender<- data.frame(actual_target_value="">->
PREDICTED_TARGET_VALUE = c("M","M","F","F"),
COST = c (0.25, 0.75, 0.0, 0.0))
R > NARROW.costs.class<- data.frame(actual_target_value="">->
PREDICTED_TARGET_VALUE = c (0,0,1,1),
COST = c (0.25, 0.75, 0.0, 0.0))
R > dt.mod1<- ore.odmdt(gender="" ~="" .,="" narrow,="" cost.matrix="">->
Summary (DT. MOD1)
R > dt.mod2<- ore.odmdt(class="" ~="" .,="" narrow,="" cost.matrix="">->
Summary (DT. MOD2)
I filed a bug so this behavior can be evaluated for a future release of Oracle Enterprise R.
-
How to retrieve the name of the partition of a deployment process
Hello
In a 11g BPEL process I need the partition name (for example - default etc.) in which the process has been deployed. As we buld available function to retrieve the instance id (ora:getCompositeInstanceId ()), we have no function to retrieve the name of the partition?Hello
Try this to affect the business.
Kind regards
Neeraj Sehgal -
return the names of columns which line values are not null.
Hi I m a new db admin guy, and I need a sql script that should return the names of columns of the given table. and the returned column must be the value (fyi - if the column contains the value null column name would not come to the o/p of sql).
Exmple:
name of the table - A
fresh status s.no name brand
1 null aa 45P
paid 2 null bb 30
3 cc paid 35P
(FYI - 1) if I give the table name (A) and s. n. (2) o/p should be - name, mark.
(2) if I give the status of tablename (A) and s. n (1) the o/p should be - name, brand.
Thank you
Krishna.
Published by: user13294228 on June 14, 2010 22:54BTW,
The previous solution is for all values of the column, if you want a specific line, you can add it in where clause.
I mean in your example, it you look like:SET serveroutput on; DECLARE l_cnt NUMBER; l_str VARCHAR2 (255) := ''; l_table_name VARCHAR2 (255) := 'YOUR_TABLE_NAME'; l_col_cond VARCHAR2 (255) := 'S_NO'; l_val NUMBER := 1; CURSOR c_col IS SELECT column_name FROM user_tab_columns WHERE table_name = l_table_name; BEGIN FOR i IN c_col LOOP EXECUTE IMMEDIATE 'SELECT COUNT (' || i.column_name || ') FROM ' || l_table_name || ' WHERE ' || l_col_cond || ' = ' || l_val INTO l_cnt; l_str := l_str || CASE WHEN l_cnt = 0 THEN '' ELSE i.column_name END || ','; END LOOP; l_str := SUBSTR (l_str, 1, LENGTH (l_str) - 1); DBMS_OUTPUT.put_line (l_str); END;
Saad,
Published by: S.Nayef on June 15, 2010 11:54
-
change the names of columns in the automatic process line fetch, edit the code
Hello
I created the master detailed form of two tables, and then I changed one of the names of columns in the table which is the detail.
of course the extraction process could not recognize the name of this column (as it is no longer exist), so I need to change the column name in the query of in the current name.
Ditto for line process transformation, to insert a new line.
I guess it's easy, but I don't know where to find the ASR process query request,
suggestions please!
Kind regards.
Published by: user8784111 on September 14, 2009 12:53 AMHello:
The detail rows are rendered in tabular form. This tabular presentation is implemented in a region of "report". You can change the query for the report region explain the column names.
CITY
-
Need to retrieve the text of a URL and store in a variable
Looking for advice here, I can do this in PHP, but I'm too new to CF doesn't know it yet. To spend of PHP to the CF would mean sending these variables in the URL of the web that I want to avoid.
Basically I have a precompiled java module I should use referring a Y or N to verify authentication.
I need to create the next scenerio:
Display with the username and password form;
Enter the name of the user as user name and password as password
From the screen of the http:/intranet/servlet/WebLogin URL, get Y or N? UserID = XXX & Password = YYY
Store the results of the verification as a global variable
My attempt of CF:
< cfform = "loginform" action = "http:/intranet/servlet/WebLogin" name
method = "Get" >
< table >
< b >
user name < td >: < table >
< td > < cfinput type = "text" name = "UserID" required = "yes".
message = "a user name is required" > < table >
< /tr >
< b >
password < td >: < table >
< td > < cfinput type = "password" name = "Password" required = "yes".
message = "a password is required" > < table >
< /tr >
< /table >
< br >
< input type = "submit" value = "Log In" >
< / cfform >
-This code works to redirect the display URL displays Y or N, but how can I not enter the result and store =)
: My PHP code to do this (works completely)
<? PHP
$url = ' http:/intranet/servlet/WebLogin? UserID = XXX & Password = YYY';
$html = file_get_contents() ($url);
If (preg_match ('/ Y /', $html, $matches))
{
echo "success."
}
on the other
{
ECHO 'no success ';
}
? >
Thank you allQuote:
Posted by: nborton
... ...
From the screen of the http:/intranet/servlet/WebLogin URL, get Y or N? UserID = XXX & Password = YYYGalloping gargoyles! There are so many things wrong here!
Anyway, if you're stuck with this approach, you will need to use cfhttp to get the result.
Something like the attached code should help you get started.
Edit: fixed error of syntax IsDefined...
Maybe you are looking for
-
Firefox v15 and up to cause my computer (MAC OSX 10.8.2) to freeze for about 30 seconds every 15 to 30 seconds and I have to turn it off with the power button. It this causes only after I opened Firefox, my computer works well before the opening of F
-
K320: how to install windows on a SSD?
To speed up my system, I bought a 64 GB SSD. The idea was to install windows 7 64 on this disc and the same boot from that. HARD original (1 TB) disk is intended to use for data application only. I added the SSD successfully to my system, but it seem
-
have spent hours setiing impression too too too use paper photo 4 x 6 can only use 8 x 11 frame can not down havew letter reset several times failing 4 x 6 each printer photosmart 8050 tab didn't tell any paper, unless I use 8 x 11 I give up
-
I'm unable to send e-mails on Windows live. Error message is 554 0r 0x800CCC6f
I can't send emails. I get an error message 554 and 0x8000ccc6f. Originally, I tried to attach something to the internet to send and that's when I started getting error messages. I'm now 8 unsent messages.
-
Just last week my laptop started acting weird. When I scroll down with my mouse, there's not down, just scrolls save. On the drop-down menus that I must use my arrows, the menu will not open. On games when I Zoom out, he zoomed back right, will no