Home » SQL & PL/SQL » SQL & PL/SQL » HOW CAN I PUT CONSTRAINTS IN A TABLE THAT HAVE EXITS IN A DATABASE
HOW CAN I PUT CONSTRAINTS IN A TABLE THAT HAVE EXITS IN A DATABASE [message #9306] Mon, 03 November 2003 00:22 Go to next message
lok raj
Messages: 14
Registered: September 2003
Junior Member
No Message Body
Re: How can I... [message #9307 is a reply to message #9306] Mon, 03 November 2003 01:44 Go to previous messageGo to next message
Maaher
Messages: 7065
Registered: December 2001
Senior Member
Please, avoid using only upper cases. It gives the reader the impression you're shouting. It not very polite to shout.

Now, for your question. I don't understand it. What do you mean with a table that has 'exits' in a database?

What I understand so far is:
1. you have a table
2. you want to add a constraint to the table

What kind of constraint did you have in mind:
- not null constraint
- check constraint
- primary key constraint
- foreign key constraint

If you would explain the basic layout of the table that would help too

MHE
Re: HOW CAN I PUT CONSTRAINTS IN A TABLE THAT HAVE EXITS IN A DATABASE [message #9308 is a reply to message #9306] Mon, 03 November 2003 01:52 Go to previous messageGo to next message
Reema
Messages: 50
Registered: July 2003
Member
Can u elaborate on oyur question more..? Do you mean to apply constarints on table...what do you mean by "Already exisiting constarints.."
Re: HOW CAN I PUT CONSTRAINTS IN A TABLE THAT HAVE EXITS IN A DATABASE [message #9309 is a reply to message #9308] Mon, 03 November 2003 02:09 Go to previous messageGo to next message
lok raj
Messages: 14
Registered: September 2003
Junior Member
yes, I want to apply constrints on table which is already exist in database but constraints are not assigned.
Re: How can I... [message #9310 is a reply to message #9307] Mon, 03 November 2003 02:18 Go to previous messageGo to next message
lok raj
Messages: 14
Registered: September 2003
Junior Member
yes u r right what u have understood.

I am trying to assign constrints to the table which are already created.

if u want the script of table i can keep here.
Re:How can I... [message #9311 is a reply to message #9309] Mon, 03 November 2003 02:21 Go to previous messageGo to next message
Maaher
Messages: 7065
Registered: December 2001
Senior Member
You can add constraints by using an ALTER TABLE _your_table_ ADD CONSTRAINT statement.

Here are the details:
ALTER table _your_table_
ADD { out_of_line_constraint
[[ out_of_line_constraint ]]...
| out_of_line_REF_constraint

With out_of_line_constraint being:
[[CONSTRAINT constraint_name]]
{ UNIQUE ( column [[, column]]... )
| PRIMARY KEY ( column [[, column]]...
| FOREIGN KEY ( column [[, column]]... references_clause
| CHECK ( condition )
} [[constraint_state]]

For a full description I'd suggest you visit http://tahiti.oracle.com (requires free subscription), the Oracle online documentation.

MHE
Re: HOW CAN I PUT CONSTRAINTS IN A TABLE THAT HAVE EXITS IN A DATABASE [message #9394 is a reply to message #9309] Fri, 07 November 2003 15:02 Go to previous messageGo to next message
ashish
Messages: 107
Registered: December 2000
Senior Member
hello,
you cann't apply constraint on a particular column of an existing table.

once the table is created you cann't apply or modify the constraint.

ashish
Re: HOW CAN I PUT CONSTRAINTS IN A TABLE THAT HAVE EXITS IN A DATABASE [message #11076 is a reply to message #9309] Thu, 04 March 2004 19:06 Go to previous message
Monika
Messages: 9
Registered: November 2000
Junior Member
If table aleady exists in database then we can put the constraint on table by altering the table.
i.e.

ALTER TABLE tablename ADD CONSTARINT constraintname
CONSTRAINT TYPE (column name)
Previous Topic: Swapping in Sql
Next Topic: Passing variable number of parameters
Goto Forum:
  


Current Time: Fri Apr 26 00:06:09 CDT 2024