Portal Home > Knowledgebase > Articles Database > oracle question
oracle question
Posted by plobby, 09-01-2009, 11:37 PM |
I have a database where in a table I have a column that is named ID but I want to limit it to strictly two characters where it cannot be over and it cannot be under -- how can this be done??
I have...
CREATE TABLE information(
id CHAR(2),
name VARCHAR2(25)
);
/
|
Posted by cselzer, 09-02-2009, 12:16 AM |
I believe...
number(2)
so...
Decent reference
http://ss64.com/ora/syntax-datatypes.html
Last edited by cselzer; 09-02-2009 at 12:20 AM.
|
Posted by plobby, 09-02-2009, 12:21 AM |
Will that limit me to numbers? Im reading on it and I cant see anywhere where it says that I can use a letter for a character such as
NN
Sorry -- I dont have access to a database to test right now
|
Posted by cselzer, 09-02-2009, 12:23 AM |
My bad, i misread. You can't use characters with that, only numbers. The reference i posted will help you further im sure. I honestly have never used oracle, and only googled what you asked and looked at a few sites. Looking further, ill edit this post in a few minutes.
|
Posted by plobby, 09-02-2009, 12:24 AM |
Oh woops I was talking about tinyint -- the original before the edit
Ill take a look there though - thanks
|
Posted by mattle, 09-02-2009, 07:01 PM |
I haven't used Oracle in about 9 years...doesn't it pad CHAR fields so you'd have something like this:
and you get:Technically, that's two characters...
I thought that was one of Oracle's differences with MySQL. Technically, the SQL standard requires you to pad CHAR fields to their full length, however, MySQL will simply return a 1 character value. (DB behaviour ref: http://troels.arvin.dk/db/rdbms/#data_types-char)
I don't think you want to limit the minimum field length (if you even can), because this would still be possible:
I think instead you want to limit the character set for the field. I don't know if Oracle has a method of handling that, but whatever it might be, it seems that it would certainly be easier to handle it in a data abstraction layer.
|
Posted by cselzer, 09-02-2009, 07:22 PM |
I was reading more on oracle.. i enjoy playing with sqlite, mysql, and postgresql. Oracle is too expensive for me to play around with it.. While writing, decided to take a look at the oracle website and found
http://www.oracle.com/technology/pro.../xe/index.html
Going to install it locally and play around with it.
|
Posted by mattle, 09-02-2009, 11:51 PM |
Cool...I didn't know about that. I'll definitely be playing around with that now! I don't suppose you ran into a comparison table between that version and the enterprise version, or if there are any known limitations?
EDIT: Just saw the Data Sheet: 4GB data limit and only executes on one processor (doesn't say anything about dual-core behavior). That will pretty much limit you from using it on any large-scale application, but it does look really useful. I'm still hopeful that Monty's MariaDB comes and blows Oracle out of the water though
Last edited by mattle; 09-02-2009 at 11:55 PM.
|
Add to Favourites Print this Article
Also Read
Cold Fusion (Views: 452)