If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > restrict blank spcae in database

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-24-08, 07:33
ankur02018 ankur02018 is offline
Registered User
 
Join Date: Jun 2007
Posts: 189
Smile restrict blank spcae in database

Hi ,
How can we restrict blank spaces such as we can restrict null by using not null
Reply With Quote
  #2 (permalink)  
Old 09-24-08, 07:47
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
Does MySQL support CHECK constraints? Memory says "not exactly"... This would be my preferred method.
__________________
George
Twitter | Blog
Reply With Quote
  #3 (permalink)  
Old 09-24-08, 07:59
shammat shammat is offline
Registered User
 
Join Date: Nov 2003
Posts: 2,407
Quote:
Originally Posted by georgev
Does MySQL support CHECK constraints?
No, not at all.
Reply With Quote
  #4 (permalink)  
Old 09-24-08, 08:25
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
Would I be right in thinking that it doesn't mind if you try and add one, it just doesn't do anything with it? Almost a forward-compatability (ha!) inclusion...
__________________
George
Twitter | Blog
Reply With Quote
  #5 (permalink)  
Old 09-24-08, 08:39
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,525
no you would not
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #6 (permalink)  
Old 09-24-08, 09:03
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
__________________
George
Twitter | Blog
Reply With Quote
  #7 (permalink)  
Old 09-24-08, 09:36
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,525
i sit corrected

my humblest apologies
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #8 (permalink)  
Old 09-24-08, 10:40
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
Ok, so without CHECK constraints, my only other offering would be to put the logic in all your sprocs that touch the data.

Can you explain why you want to do this?
__________________
George
Twitter | Blog
Reply With Quote
  #9 (permalink)  
Old 09-24-08, 10:45
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,525
"sprocs" is such a microsoftian word

how do you know he's using spocs in MySQL?

and how would this prevent entering "blank spaces" (as though there were any other kind of spaces) through plain old DML?
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #10 (permalink)  
Old 09-24-08, 11:34
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
Lol, ok Rudy.

I don't know the OP is using sprocs (or Stored Procedures/Routines if you prefer), so I should have used a more blanket statement.

Your data access layer will have to handle blank strings for you.

In Microsofts SQL Server there is a function called NullIf() which I would use in this scenario to "convert" blank strings to NULL values. Whether this particular function exists in MySQL is a different question and not one I able to answer at this juncture (dev.mysql just won't load at this location!)
__________________
George
Twitter | Blog
Reply With Quote
  #11 (permalink)  
Old 09-24-08, 16:42
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
__________________
George
Twitter | Blog
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On