Geeks Talk

Prepare for your Next Interview


Welcome to the Geeks Talk forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact us.

create table with check constraint rule in oracl

This is a discussion on create table with check constraint rule in oracl within the Oracle forums, part of the Databases category; i have table with Phone column with char data type, the phone column must be of same format (####)-######. Hence create a Rule by name Rule_Phone and bind the rule ...

Go Back   Geeks Talk > Databases > Oracle
Register Blogs FAQ Tag Cloud Calendar Mark Forums Read

Oracle Oracle 9i & Oracle 10g Knowledge Base Learn and Share Oracle Technology related articles, white papers, tutorials / study materials, example codes, FAQ's, Tips and Tricks.

Reply

 

LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 11-08-2008
Contributing Member
 
Join Date: May 2008
Location: Chennai
Posts: 30
Thanks: 6
Thanked 0 Times in 0 Posts
sureshkumar.mtech is on a distinguished road
create table with check constraint rule in oracl

i have table with Phone column with char data type, the phone column must be of same format (####)-######. Hence create a Rule by name Rule_Phone and bind the rule to phone columns of all tables.
Check the above by inserting
i. 234-2372727
ii. (0821)-2404021
into the phone columns of the table
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 11-09-2008
Moderator
 
Join Date: Jun 2007
Location: Bangalore,India
Posts: 1,853
Thanks: 9
Thanked 168 Times in 142 Posts
debasisdas has a spectacular aura aboutdebasisdas has a spectacular aura about
Re: create table with check constraint rule in oracl

check constraints ,check for values not formats.
Reply With Quote
  #3 (permalink)  
Old 11-14-2008
Expert Member
 
Join Date: Apr 2007
Location: Bangalore
Posts: 517
Thanks: 30
Thanked 63 Times in 61 Posts
susarlasireesha will become famous soon enough
Re: create table with check constraint rule in oracl

Try this
CREATE TABLE pp(phone VARCHAR2(13) CONSTRAINT pp_check CHECK( INSTR(SUBSTR(phone,6,1),')') >0
AND INSTR(SUBSTR(phone,1,1),'(') >0 AND INSTR(SUBSTR(phone,7,1),'-') >0 AND TO_NUMBER(REPLACE(REPLACE(REPLACE(phone,')',0),'(',0),'-',0))>0) );


Quote:
Originally Posted by sureshkumar.mtech View Post
i have table with Phone column with char data type, the phone column must be of same format (####)-######. Hence create a Rule by name Rule_Phone and bind the rule to phone columns of all tables.
Check the above by inserting
i. 234-2372727
ii. (0821)-2404021
into the phone columns of the table
__________________
Sireesha
Reply With Quote
The Following User Says Thank You to susarlasireesha For This Useful Post:
  #4 (permalink)  
Old 03-30-2009
Junior Member
 
Join Date: Mar 2009
Location: Chennai
Posts: 27
Thanks: 0
Thanked 2 Times in 2 Posts
phanikanthmn is on a distinguished road
Wink Re: create table with check constraint rule in oracl

try this

create table t1(phone varchar2(15) constraint pk_check check(translate(phone,' -0123456789()',' '));
Reply With Quote
Reply

  Geeks Talk > Databases > Oracle

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads

Thread Thread Starter Forum Replies Last Post
Create a table in excel demo676 WinRunner 1 02-13-2008 09:08 AM
Create same table JobHelper Database General 5 08-07-2007 01:03 PM
Check the company code entry xxxx in the table 169p nsymphony SAP R/3 0 07-23-2007 11:13 PM
Can you create internal table dynamically Geek_Guest SAP R/3 0 07-19-2007 09:55 AM
Check Constraint christia SQL 2 07-30-2006 07:16 PM


All times are GMT -4. The time now is 02:56 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.3.1
Copyright © 2009 GeekInterview.com. All Rights Reserved