SQL & PL/SQL :: Query For Columns In Table Including Constraints?
Jul 23, 2010I want a query for all the columns in a table including there constraints and indexes of a "SCOTT" schema
View 7 RepliesI want a query for all the columns in a table including there constraints and indexes of a "SCOTT" schema
View 7 Replieswhat command is used to create a table by copying the structure of another table including constraints ?
View 2 Replies View RelatedI would like to print all the constraints on all columns given a table name.
Example:
SQL>@constrnts
Enter Table Name: emp
empno ---- Primary key
deptno ---- foreign key references Dept(deptno)
I have a two question.
Question 1:How to select all columns from table except those columns which i type in query
Question 2:How to select all columns from table where all columns are not null without type each column name which is in empty data
I want to create a store procedure to copy data from a source tables(which may not have any constraints defined) to a table which has primary key, foreign key and unique key constraints.
Any records which are rejected due to these constraints not being satisfied need to go another table.
Once the initial data load is done, these procedures need to be automated(through cron) to do the future incremental uploads in the same manner.
query to know number of columns in a table i.e.
if I want to know how many number of colums are present in a specific table then what would be the query.
I was given a task by manager to keep track of changes on a given table including os_user who made it.Should I create a trigger on it (on any update, insert, delete etc.) or there is a better way of doing it ?I think there could be some info already in some data dictionary views or something like it.
If I CREATE MATERIALIZED VIEW LOG on that table.
Lets say I have a table in ORACLE database like:
ACC_ID | ACC_AMT
111 | 10000
111 | 12000
111 | 14000
222 | 25000
222 | 30000
333 | 18000
333 | 27000
333 | 13000
333 | 15000
I want to get the output as:
ACC_ID_1 | ACC_AMT_1 | ACC_ID_2 | ACC_AMT_2 | ACC_ID_3 | ACC_AMT_3
111 | 10000 | 222 | 25000 | 333 | 18000
111 | 12000 | 222 | 30000 | 333 | 27000
111 | 14000 | null | null | 333 | 13000
null | null | null | null | 333 | 15000
I need each different ACC_ID with ACC_AMT in different columns. The table may have other different ACC_ID also, but I will fetch only what I need. What is the best way to do this?
So far I have tried this:
SELECT
(CASE WHEN ACC_ID=111 THEN ACC_ID END) AS ACC_ID_1,
(CASE WHEN ACC_ID=111 THEN ACC_AMT END) AS ACC_AMT_1,
(CASE WHEN ACC_ID=222 THEN ACC_ID END) AS ACC_ID_2,
(CASE WHEN ACC_ID=222 THEN ACC_AMT END) AS ACC_AMT_2,
(CASE WHEN ACC_ID=333 THEN ACC_ID END) AS ACC_ID_3,
(CASE WHEN ACC_ID=333 THEN ACC_AMT END) AS ACC_AMT_3
FROM <TABLE_NAME>
But I am not getting the desired result.
I am trying to search a word which starts with 'FRA' in any columns and any tables.
I am unable to find what is generating a join datasets in the webservice from teh database as it is not apparent within the 100 tables.
I ahve looked into
Re: How to search in all rows and all columns?
Re: SQL Search Query?
but none of these queries is working out for me as I am a user with no tables on its own but rather a user quering other tables.I think its a tweak on which dat a dictionary I can view
select distinct substr (table_name, 1, 14) "Table",
substr (t.column_value.getstringval (), 1, 50) "Column/Value"
from all_cons_columns,
table
(xmlsequence
(dbms_xmlgen.getxmltype ('select ' || column_name
|| ' from ' || table_name
|| ' where upper('
|| column_name
|| ') like upper(''%' || 'fra'
|| '%'')'
).extract ('ROWSET/ROW/*')
)
) t
order by "Table";
running teh above query got me thsi error:
ORA-19202: Error occurred in XML processing
ORA-00942: table or view does not exist
ORA-06512: at "SYS.DBMS_XMLGEN", line 288
ORA-06512: at line 1
19202. 00000 - "Error occurred in XML processing%s"
*Cause: An error occurred when processing the XML function
*Action: Check the given error message and fix the appropriate problem
the query, to get the foreign key constraints and related table fro give table.
View 2 Replies View RelatedHow do know all the constraints that are present on the data in a table in oracle ??
View 2 Replies View RelatedWhen we create a duplicate table, we use the below query:
create table table2 as select * from table1;
But table2 is created without any constraints inherited from table1.Can I know how can i create the table with all the constraints existing in parent table.
I want to truncate table partition but I'm getting error:
CODEORA-02266: unique/primary keys in table referenced by enabled foreign keys
because of table has a nested table. Currently this column is not in use so I could drop it, but I want to avoid it (table is huge). Is there another posibility to do truncate partitions in this table? ALTER TABLE ... SET UNUSED doesn't resolve the problem.
can a table level check constraints have conditional checking (if else clause or case conditional structures) and checks which are limited through something like a where clause which inside the table level check constraints.And can a table level check constraints refer to a column in another table column which should have a the same value.
View 1 Replies View RelatedI knew, how to enable or disable a constraint on a table.
>alter table <table_name> disable constraint <constraint_name>;
But if we know all the data is correct, it's better to disable all constraints to improve the performance.
We are allowed to Disable or Enable only a single constraint.
Enable or Disable All Constraints.
i am a beginner in SQL and want to create a table with the following constraints :
'orderno' should be primary key and start with o
'clientno' should be foreign key
'ordr date' is not null
'salesmanno' foreign key
'delytype' default value 'f' and possible value ( f or p)
'delydate' cannot be less than order date
'orderstatus' values ('in process.......)
here's my
create table sales_order(orderno varchar2(6) like 'o%' primary key,
clientno varchar2(6) foreign key references client_master(clientno),deldate date not null,dellyaddr varchar2(25),salesmanno varchar2(6) foreign key references salesman_master(salesmanno), delytype char(1) default 'f',billyn char(1),delydate date check > orderdate,orderstatus varchar2(10)check ('in process','fullfilled','cancelled');
how to copy data and constraints from one table to another table
View 8 Replies View Relatedthrough Difference between table Level, column Level ,row level constraints.
View 8 Replies View Related1. how can i impose a restriction on a table so that the data gets updated only specific period of time say 9 a.m. to 10 p.m.
2. Can i use bulk collect in dynamic sql? If yes how?
I know that you can view all constraints in a table using $USER_CONSTRAINTS or $USER_INDEXES view. What i find difficult is that the information in those views is not really well presented.
I find it very hard to follow. For example, just to find out which columns are foreign keys and which tables they refer to is really tedious. Is there a simpler way to view all the constraints especially foreign keys of a table and including which table columns they refer to in the child table.
I like to see a diagramatic representaion of all the tables involved so i like to see both the parent and the child tables, which columns are related and using which FKs etc. is there an easier way to view this information?
I have created table as below
create table emp_temp as select * from emp;
the table is created, but the constraints are not copied. Is there any way to copy all the constraints.
can you use alter table command to disable/enable constraints in a form if you can how, if you cant why
View 4 Replies View RelatedAm creating a table based on some integrity constraints, but it's not working.
CREATE TABLE member
(
member_id NUMBER(10),
last_name VARCHAR2(25) NOT NULL,
first_name VARCHAR2(25),
[code],,,
Error:
Error report:
SQL Error: ORA-02270: no matching unique or primary key for this column-list
02270. 00000 - "no matching unique or primary key for this column-list"
*Cause: A REFERENCES clause in a CREATE/ALTER TABLE statement gives a column-list for which there is no matching unique or primary key constraint in the referenced table.
*Action: Find the correct column names using the ALL_CONS_COLUMNScatalog view
My supervisor wants to remove all the archivelogs since it was just a test for 1 year the DB is not actually YET been used. Problem is they want it to be used as soon as possible w/o recreating again the database and just removing some data on tables and removed archive logs. how to safely removed the existing archived logs and create a full backup with archived fresh to sequence 1.
View 2 Replies View RelatedI use Database 11g .
I have 2 BLOB columns include pdf files.
How can I create one BLOB column include one one pdf file? merge 2 pdf files into one file.
In an 11g database is it possible to create an awr report including the current hour or do I always have to wait till the full hour?
View 1 Replies View RelatedIs it possible to create a completely self-contained installer that deploys all the Oracle files along with the application (i.e. the user doesn't need to install instant client, mess around with configuring path environment variables, etc.)?
[URL]
What if as part of the installer, I need to test a connection string entered by the user? That seems to be the sticking point for me. Even after installing the instant client (from the x64 xcopy zip file using install.bat), the installer is not able to connect to the database.
And, the application is 64 bit only (we need the 64 bit Crystal Reports runtime), meaning I've got the 64 bit Oracle instant client installed. I suspect that might be the problem since the msiexec installer process is 32 bit.
I'm a beginner in PL/SQL ! --> " get_sql_metadata(p_query IN Varchar2) RETURN VARCHAR2;" I have to display the names and columns of the query by using the package dbms_sql and how can I know how many columns will have my query.
View 4 Replies View RelatedI'm working on a Oracle Database, and I'm gettin incorrect results when including a date field in the select list which is NULL in the table.
This works correctly and returns exactly one row:
SELECT firstField FROM table WHERE firstField = 'value'
while this doesn't and returns no rows:
SELECT firstField, secondField FROM table WHERE firstField = 'value'
Where secondField is of type date and its value is NULL (00-000-00). Note that the only thing that changes is the select list.
I have several databases that i've recently upgraded from 9i to 11g. With all of them, the automatic stats gathering process has worked just fine every night during the maintenance window.
However, i have this other database that i created and it seems that the only stats being gathered are on the sys and system schemas and not the actual schema that holds all of our tables.
I did some searching, but i'm not sure i was using the right search terms, because i came up empty.
BANNER
-----------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
PL/SQL Release 11.2.0.1.0 - Production
CORE 11.2.0.1.0 Production
TNS for Solaris: Version 11.2.0.1.0 - Production
NLSRTL Version 11.2.0.1.0 - Production