Re: Help Data-Types

From: Alan <alanshein_at_erols.com>
Date: Mon, 19 Aug 2002 09:47:39 -0400
Message-ID: <ajqsti$1d0je7$1_at_ID-114862.news.dfncis.de>


Here is some general info to help guide you with this question and others. General rule of thumb: Use a text/character data type unless you need to perform mathematical operations or sorts on the numbers. One important reason is that with number data types, leading zeros are not stored. This can be a problem under certain circumstances, such as with Zip code in the U.S. (the numbers run from 00001 to 99999). The disadvantage is that if you sort the (text) data, you may get results you don't like. For example, in this set of data:
(1,10,100,2,21), the text data type will sort 1,10,100,2,21

For example, consider the following:

SQL> desc test;

 Name                            Null?    Type
 ------------------------------- -------- ----
 ALPHA                                    VARCHAR2(4)
 NUMB                                     NUMBER(4)

SQL> insert into test values ('1',1);

1 row created.

SQL> insert into test values ('10',10);

1 row created.

SQL> insert into test values ('100',100);

1 row created.

SQL> insert into test values ('2',2);

1 row created.

SQL> insert into test values ('21',21);

1 row created.

SQL> insert into test values ('001',001);

1 row created.

SQL> select * from test;

ALPH NUMB
---- ---------

1            1
10          10
100        100
2            2
21          21
001          1

6 rows selected.

SQL> select * from test order by alpha;

ALPH NUMB
---- ---------

001          1
1            1
10          10
100        100
2            2
21          21

6 rows selected.

SQL> select * from test order by numb;

ALPH NUMB
---- ---------

1            1
001          1
2            2
10          10
21          21
100        100

6 rows selected.

"Dave" <dave_at_dmcomm.com> wrote in message news:_Ug79.27$Tl4.10801289_at_news.incc.net...
> Just a quick question on a datatypes since I'm a young novice.
> What the heck would an IP address go under? Text? Integer (long, short?)
??
>
> Thanks for the help.
> D
>
>
Received on Mon Aug 19 2002 - 15:47:39 CEST

Original text of this message