473,434 Members | 1,494 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,434 software developers and data experts.

How to drop Not Null constraint (system generated)

Hello,

I created one table say "Table1" with one column say "Column1" with constraint Not Null. Oracle generated its own name for this constraint. Say SYS_C#########.

I want to delete this constraint using one sql script. But how i will find out the constraint name to drop this constraint?

-Dhiraj
May 21 '07 #1
3 69713
chandu031
78 Expert
Hello,

I created one table say "Table1" with one column say "Column1" with constraint Not Null. Oracle generated its own name for this constraint. Say SYS_C#########.

I want to delete this constraint using one sql script. But how i will find out the constraint name to drop this constraint?

-Dhiraj
Hi,

All the Not null constraints will be stored in a table called ALL_CONS_COLUMNS which has Owner, table_name,column_name,constraint_name and position(in case of primary key)

So to get the constraint name for just a NOT NULL constraint your query would look like this :

Expand|Select|Wrap|Line Numbers
  1.  
  2. SELECT CONSTRAINT_NAME FROM ALL_CONS_COLUMNS WHERE OWNER = <user_name> AND TABLE_NAME = <table_name>
  3. AND COLUMN_NAME = <column_name> 
  4.  
May 21 '07 #2
frozenmist
179 Expert 100+
Hi,
A simple solution that I can think of if you know the column name is that
you can just alter the column to allow null. This would take out the constraint , wouldn't it?
If you want the constraint name as such, it would be better if you do what Chandu
suggested.
Eg:
If your table was like
create table table1 (col1 integer not null)
then you can use
Expand|Select|Wrap|Line Numbers
  1. Alter table table1 modify col1 integer null
  2.  
to remove the constraint.

Hope it helped
Cheers
May 21 '07 #3
chandu031
78 Expert
Hi,

If you just want to drop the not null constraint then there is a better way of doing it.

Just use the ALTER TABLE command:

Expand|Select|Wrap|Line Numbers
  1.  
  2. ALTER TABLE <table_name> MODIFY <column> <datatype> NULL
  3.  
  4.  
Of course this does not work the other way round i.e from NULL to NOT NULL
if there are already NULLs in your table. It will work if the field doesn't have NULLs
May 21 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Kevin Haugen | last post by:
SQL SERVER 2000 System let's you alter the system tables and add indexes. However, it won't let you drop the index afterward. Anybody know how to drop an index on a system table? Thanks, ...
5
by: Charts | last post by:
I recently upgraded to VS2005. I noticed that in ASP.NET project, the system generated codes are missing from default.aspx.cs file. While I used to be able to see it in VS2003 project. Now, if I...
4
by: Ken D. | last post by:
I have an asp page that collects data on referrals. The user inputs the information and selects the rep to receive the referral. My data is being saved to a backend database (SQL) and the user is...
5
by: annecarterfredi | last post by:
Is there any command (alter table ...?) to drop 'Not Null' constraint on a column? I have a column CODE which has 'Not Null' constraint defined and I want to drop 'Not Null'. Please let me know. ...
1
by: abhu50 | last post by:
i have created table with unnamed check constraint so pl help me to drop this check constraint also about dropping the foreign key that is unnamed???????????
5
by: ganeshshegde | last post by:
How to add not null constrint to an existing table? i tried with "alter table emp add constraint not_null_name not null(name)" command but it's giving error .......... alter table emp add...
8
by: Elfae | last post by:
I have searched high and low for a sample for this, and I just can't find any. Sorry for the length! Background Information The issue revolves around setting up a system-generated increase in...
1
by: femina | last post by:
when i create a table from another table with as subquery the not null constraint gets copied but the primary constraint is not copied. can you help me with the reason behind this thanks in advance
4
by: rismy | last post by:
The code for PDF attachment (system generated)via Email
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.