테스트중 number 타입에 의문이 들었습니다.
그래서 직접 테스트를 해봤습니다. 더욱 의문이 드네요 이게 맞는건가...^^
-- 테이블생성 create table test_pp (a number(5,2), b number(5,-2)); -- a컬럼에 테스트 insert into test_pp (a) values (4); insert into test_pp (a) values (47); insert into test_pp (a) values (478); >> 이후 에러발생 insert into test_pp (a) values (4789); insert into test_pp (a) values (43210); insert into test_pp (a) values (432101); -- 결론 뒤에 정밀도(2)공간을 미리 차지한다. 그래서 3자리 이상의 수는 못들어간다. insert into test_pp (b) values (4); -- 결과 0 insert into test_pp (b) values (47); -- 결과 0 insert into test_pp (b) values (478); -- 결과 500 insert into test_pp (b) values (4789); -- 결과 4800 insert into test_pp (b) values (43210); -- 43200 -- 메뉴얼은 이렇습니다. If you specify a negative scale, Oracle Database rounds the actual data to the specified number of places to the left of the decimal point. For example, specifying (7,-2) means Oracle Database rounds to the nearest hundredths, as shown in Table 26-1. -- 7,456,123.89 > NUMBER(7,-2) > 7456100 -- 2차 테스트 insert into test_pp (b) values (50); -- 결과 100 짐작하는 결론 , 1자리 수는 -2(2자리가 안되므로 소수점이) 0으로 표시 50은 2자리이며 올림수이므로 100 표시 -- 그렇다면 결론은 무조건 2자리 수에서 올림수 가 있으면 반올림하는건가요?
뭐가 의문인지가 안나와 있네.
결론만 있고 의문은 없군?
결론은 (수치 표시 형식)을 벗어나는 부분에 대해선 반올림 처리하는거지.
(5, 2) ==> 999.99 (소수 2째자리까지 표시, 3째자리에서 반올림) ==> ROUND(입력값, 2)
(5, -2) ==> 99900 (100단위까지 표시, 십단위에서 반올림) ==> ROUND(입력값, -2)
제가 테스트 한게 맞는지 궁금했어요
지금 보니 질문이 이상했네요 :)
맞긴하군요.. 감사합니다!
이따 보자~