Re: Number datatypes
Date: Tue, 18 Feb 2003 09:01:51 +0100
Message-ID: <1045555075.921927_at_news.thyssen.com>
"Jen" <jenmw_at_comcast.net> schrieb im Newsbeitrag news:9b5e1aac.0302171355.4dee93ff_at_posting.google.com...
> I have created a column gpa for a table students.
>
>
> SID NOT NULL
> VARCHAR2(4)
> SNAME NOT NULL
> VARCHAR2(20)
> GPA NOT NULL NUMBER
> BIRTHDATE NOT NULL
> VARCHAR2(15)
> MAJOR
> VARCHAR2(5)
> GENDER
> VARCHAR2(6)
>
> When I query the table, it rounds the gpa up. like this:
>
>
> SID SNAME GPA BIRTHDATE MAJOR GENDER
> ---- -------------------- ---------- --------------- ----- ------
> S01 GINNY FLeck 3.5 01-JAN-79 ACC FEMALE
> S02 Arby Bee 1 09-OCT-45 PED MALE
> S03 B. V. DEEs 2.9 15-MAR-60 CSS MALE
> S04 Sid E. Slicker 3.7 25-DEC-70 CSS MALE
> S05 June Bride 4 22-OCT-69 CSS FEMALE
> S06 Wilma Flinstone 2 11-NOV-68 ACC FEMALE
> S07 DOUG OUT 3.3 22-JUN-71 HIS MALE
> S08 Wanda Full 4 04-JUL-71 CSS FEMALE
>
>
> I need to know how to alter the column so that the format is #.##...
> For example, I would like Arby Bee's GPA to be 1.00 (2 decimal places
> to the right). B.V.Dee's GPA should be 2.88(which is what I entered it
> as) instead of 2.9. Could someone please tell me how I can alter the
> table so that I get two decimal places and no rounding without having
> to put the format in the select statement?
>
> Thanks,
> Jen
Hi Jen,
the statement would be like:
alter table students modify (gpa number(12,2));.
But: you can't modify the column if the table is not empty.
So you have to save your data to a kind of temp table,
truncate / delete the original table (records), alter the
column definition and put the data back in.
hth,
Guido
Received on Tue Feb 18 2003 - 09:01:51 CET