Create a table with only scale specification for a column

Hi All,

Just came across a peculiar way of specifying only the column scale and not its precision, so thought of sharing with all. It looks pretty simple but could be a handy tip for table designs.

Scenario: Create a table CONT_EMPS where Salary column must store values upto 2 places of decimals (i.e. scale is 2). Here, note that no precision has been specified for the Salary column. Lets see how to do it.

4 SAL NUMBER(*,2))
5 /
Table created.

Name         Null?    Type
------------ -------- ----------------------------
EMPID                 NUMBER
EMPNAME               VARCHAR2(256)
SAL                   NUMBER(38,2)

When I specify ‘*’ in place of precision, Oracle treats it as the maximum precision allowed for the column. Additionally, this convention doesn’t applies to PL/SQL data type declaration.
Bye for now.

Related articles

6 thoughts on “Create a table with only scale specification for a column

  1. Hi Siva

    SQL Server supports number datatype precision upto 38 digits. MySQL supports its till 65 digits.

    As per Oracle documentation, Oracle supports the portability of numbers with precision equal or less than 38 digits. Therefore, reg the mentioned feature, I believe it is supported by Oracle only.

  2. This will be the right blog for everyone who wants to learn about this topic. You recognize so a lot its just about difficult to argue with you (not that I in fact would want…HaHa). You absolutely put a new spin on a topic thats been written about for years. Good things, just very good!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s