473,403 Members | 2,183 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

7.4's INFORMATION_SCHEMA.Columns View

This is part of the Columns View, if you add a numeric field to your table
and don't provide any Length or Precision then :

numeric_precision is returned as 65535
numeric_scale is returned as 65531

Is this what you'd expect, and what does it mean to create a column with
no Length or Precision, I'm using pgAdmin to create the tables and
columns, but the tables are created and seem to work.

====================================

CAST(
CASE (CASE WHEN t.typtype = 'd' THEN t.typbasetype ELSE
a.atttypid END)
WHEN 21 /*int2*/ THEN 16
WHEN 23 /*int4*/ THEN 32
WHEN 20 /*int8*/ THEN 64
WHEN 1700 /*numeric*/ THEN ((CASE WHEN t.typtype = 'd' THEN
t.typtypmod ELSE a.atttypmod END - 4) >> 16) & 65535
WHEN 700 /*float4*/ THEN 24 /*FLT_MANT_DIG*/
WHEN 701 /*float8*/ THEN 53 /*DBL_MANT_DIG*/
ELSE null END
AS cardinal_number)
AS numeric_precision,

====================================

CAST(
CASE WHEN t.typtype = 'd' THEN
CASE WHEN t.typbasetype IN (21, 23, 20) THEN 0
WHEN t.typbasetype IN (1700) THEN (t.typtypmod - 4) &
65535
ELSE null END
ELSE
CASE WHEN a.atttypid IN (21, 23, 20) THEN 0
WHEN a.atttypid IN (1700) THEN (a.atttypmod - 4) & 65535
ELSE null END
END
AS cardinal_number)
AS numeric_scale,


---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to ma*******@postgresql.org)

Nov 23 '05 #1
14 3853
mi**********@mygenerationsoftware.com writes:
This is part of the Columns View, if you add a numeric field to your table
and don't provide any Length or Precision then : numeric_precision is returned as 65535
numeric_scale is returned as 65531


Yeah, that's what you'd get for a numeric field with no length
constraint. (I suspect varchar with no length constraint will
display funny as well.)

The SQL spec doesn't allow unconstrained lengths for these types
so it gives no guidance about what to display in the information_schema
views. Any opinions?

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to ma*******@postgresql.org

Nov 23 '05 #2
mi**********@mygenerationsoftware.com writes:
This is part of the Columns View, if you add a numeric field to your table
and don't provide any Length or Precision then : numeric_precision is returned as 65535
numeric_scale is returned as 65531


Yeah, that's what you'd get for a numeric field with no length
constraint. (I suspect varchar with no length constraint will
display funny as well.)

The SQL spec doesn't allow unconstrained lengths for these types
so it gives no guidance about what to display in the information_schema
views. Any opinions?

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to ma*******@postgresql.org

Nov 23 '05 #3
On Fri, Jun 18, 2004 at 11:42:29 -0400,
Tom Lane <tg*@sss.pgh.pa.us> wrote:

The SQL spec doesn't allow unconstrained lengths for these types
so it gives no guidance about what to display in the information_schema
views. Any opinions?


It might make some sense to use the maximum length supported by the type
for the precision. The documentations says that numeric is limited to
1000 digits.

If there isn't a set scale for the type, then NULL would probably make the
most sense.

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Nov 23 '05 #4
On Fri, Jun 18, 2004 at 11:42:29 -0400,
Tom Lane <tg*@sss.pgh.pa.us> wrote:

The SQL spec doesn't allow unconstrained lengths for these types
so it gives no guidance about what to display in the information_schema
views. Any opinions?


It might make some sense to use the maximum length supported by the type
for the precision. The documentations says that numeric is limited to
1000 digits.

If there isn't a set scale for the type, then NULL would probably make the
most sense.

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Nov 23 '05 #5
Ah yes, is that in pg_types, good idea, I might override that after I make
the query.
On Fri, Jun 18, 2004 at 11:42:29 -0400,
Tom Lane <tg*@sss.pgh.pa.us> wrote:

The SQL spec doesn't allow unconstrained lengths for these types
so it gives no guidance about what to display in the information_schema
views. Any opinions?


It might make some sense to use the maximum length supported by the type
for the precision. The documentations says that numeric is limited to
1000 digits.

If there isn't a set scale for the type, then NULL would probably make the
most sense.


---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Nov 23 '05 #6
Ah yes, is that in pg_types, good idea, I might override that after I make
the query.
On Fri, Jun 18, 2004 at 11:42:29 -0400,
Tom Lane <tg*@sss.pgh.pa.us> wrote:

The SQL spec doesn't allow unconstrained lengths for these types
so it gives no guidance about what to display in the information_schema
views. Any opinions?


It might make some sense to use the maximum length supported by the type
for the precision. The documentations says that numeric is limited to
1000 digits.

If there isn't a set scale for the type, then NULL would probably make the
most sense.


---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Nov 23 '05 #7
mi**********@mygenerationsoftware.com writes:
I noticed that there is no INFORMATION_SCHEMA.Indexes ? isn't there
supposed to be one.


Nope. Indexes are not a concept used in the SQL spec at all (they
consider 'em an implementation detail), so they'd hardly want to
standardize a view to describe 'em.

You can look at the constraints views to find out about unique and
primary key constraints, which are implemented by indexes in PG.
But that won't tell you about indexes made by CREATE INDEX.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to ma*******@postgresql.org so that your
message can get through to the mailing list cleanly

Nov 23 '05 #8
mi**********@mygenerationsoftware.com writes:
I noticed that there is no INFORMATION_SCHEMA.Indexes ? isn't there
supposed to be one.


Nope. Indexes are not a concept used in the SQL spec at all (they
consider 'em an implementation detail), so they'd hardly want to
standardize a view to describe 'em.

You can look at the constraints views to find out about unique and
primary key constraints, which are implemented by indexes in PG.
But that won't tell you about indexes made by CREATE INDEX.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to ma*******@postgresql.org so that your
message can get through to the mailing list cleanly

Nov 23 '05 #9
>>> The SQL spec doesn't allow unconstrained lengths for these types
so it gives no guidance about what to display in the information_schema
views. Any opinions?


If there isn't a set scale for the type, then NULL would probably make the
most sense.


After more thought I like returning NULL for both precision and scale in
the case of unconstrained numeric columns. Any other value is
arbitrary. In particular, the 1000 cited in the docs is *very*
arbitrary, and I don't think it actually constrains what you can store,
only what you can declare as a column precision. [tries it...] Yup,
I can store "power(10.0, 10000)" in an unconstrained numeric column.
It seems to fail around 10^140000 but I'm not sure where that limit
is coming from exactly...

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html

Nov 23 '05 #10
>>> The SQL spec doesn't allow unconstrained lengths for these types
so it gives no guidance about what to display in the information_schema
views. Any opinions?


If there isn't a set scale for the type, then NULL would probably make the
most sense.


After more thought I like returning NULL for both precision and scale in
the case of unconstrained numeric columns. Any other value is
arbitrary. In particular, the 1000 cited in the docs is *very*
arbitrary, and I don't think it actually constrains what you can store,
only what you can declare as a column precision. [tries it...] Yup,
I can store "power(10.0, 10000)" in an unconstrained numeric column.
It seems to fail around 10^140000 but I'm not sure where that limit
is coming from exactly...

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html

Nov 23 '05 #11
Well, does it have an actual length, that seems strange to me, is in
infinitely large? I guess I'm just not used to being allowed not to
define something, I'm a Microsoft type (he he) don't get me wrong, we've
taken our product into all kinds of open source areas, what an eye opener
it's been. I really like PostgreSQL, it's so much more powerful than MySQL
yet you don't hear much about it? Anyway, I'm working on our foreign key
queries tonight, we're pulling back lots of good meta data.

I noticed that there is no INFORMATION_SCHEMA.Indexes ? isn't there
supposed to be one. Thank goodness PostgreSQL has good documentation for
the system catalogs.
mi**********@mygenerationsoftware.com writes:
This is part of the Columns View, if you add a numeric field to your
table
and don't provide any Length or Precision then :

numeric_precision is returned as 65535
numeric_scale is returned as 65531


Yeah, that's what you'd get for a numeric field with no length
constraint. (I suspect varchar with no length constraint will
display funny as well.)

The SQL spec doesn't allow unconstrained lengths for these types
so it gives no guidance about what to display in the information_schema
views. Any opinions?

regards, tom lane


---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to ma*******@postgresql.org so that your
message can get through to the mailing list cleanly

Nov 23 '05 #12
Well, does it have an actual length, that seems strange to me, is in
infinitely large? I guess I'm just not used to being allowed not to
define something, I'm a Microsoft type (he he) don't get me wrong, we've
taken our product into all kinds of open source areas, what an eye opener
it's been. I really like PostgreSQL, it's so much more powerful than MySQL
yet you don't hear much about it? Anyway, I'm working on our foreign key
queries tonight, we're pulling back lots of good meta data.

I noticed that there is no INFORMATION_SCHEMA.Indexes ? isn't there
supposed to be one. Thank goodness PostgreSQL has good documentation for
the system catalogs.
mi**********@mygenerationsoftware.com writes:
This is part of the Columns View, if you add a numeric field to your
table
and don't provide any Length or Precision then :

numeric_precision is returned as 65535
numeric_scale is returned as 65531


Yeah, that's what you'd get for a numeric field with no length
constraint. (I suspect varchar with no length constraint will
display funny as well.)

The SQL spec doesn't allow unconstrained lengths for these types
so it gives no guidance about what to display in the information_schema
views. Any opinions?

regards, tom lane


---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to ma*******@postgresql.org so that your
message can get through to the mailing list cleanly

Nov 23 '05 #13
I agree, the current numbers are misleading, nothing other than null
really makes sense, at least the consumers of it can decide what to do if
they need to rather than check for some strange number, sounds good to me.

After more thought I like returning NULL for both precision and scale in
the case of unconstrained numeric columns. Any other value is
arbitrary. In particular, the 1000 cited in the docs is *very*
arbitrary, and I don't think it actually constrains what you can store,
only what you can declare as a column precision. [tries it...] Yup,
I can store "power(10.0, 10000)" in an unconstrained numeric column.
It seems to fail around 10^140000 but I'm not sure where that limit
is coming from exactly...

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html


---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to ma*******@postgresql.org)

Nov 23 '05 #14
I agree, the current numbers are misleading, nothing other than null
really makes sense, at least the consumers of it can decide what to do if
they need to rather than check for some strange number, sounds good to me.

After more thought I like returning NULL for both precision and scale in
the case of unconstrained numeric columns. Any other value is
arbitrary. In particular, the 1000 cited in the docs is *very*
arbitrary, and I don't think it actually constrains what you can store,
only what you can declare as a column precision. [tries it...] Yup,
I can store "power(10.0, 10000)" in an unconstrained numeric column.
It seems to fail around 10^140000 but I'm not sure where that limit
is coming from exactly...

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html


---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to ma*******@postgresql.org)

Nov 23 '05 #15

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Pachydermitis | last post by:
Hi I need to see all the indexes in a database. The ID has dbo rights to the database, but not to the master. I can't see anything in INFORMATION_SCHEMA.CHECK_CONSTRAINTS or...
3
by: Tina Harris | last post by:
I ran the following query in Query Analyzer for a 7 column table. SELECT c.name,c.colid FROM syscolumns c WHERE c.id=925962375 ORDER BY c.colid The results were: I_CSD 1 X_STE_XML 2...
3
by: Dave Sisk | last post by:
Hi Folks: I'm a little new to SQLServer, so please pardon my ignorance! I've found the INFORMATION_SCHEMA views for TABLES, COLUMNS, and TABLE_CONSTRAINTS. I'm looking for the views that will...
0
by: mike.griffin | last post by:
This is part of the Columns View, if you add a numeric field to your table and don't provide any Length or Precision then : numeric_precision is returned as 65535 numeric_scale is returned as...
0
by: BB | last post by:
Hi There, just moved over from SQL Server to mySQL and finding my way about. In SQL Server there was a way of retrieving (and setting) metaproperties for columns and tables. The closest I see to...
2
by: parkc | last post by:
How do you change the order of key columns in a primary key and view the difference between two tables that have the same name? For example, table x has a primary key called pk_x. PK_x contains...
1
by: Shrek | last post by:
if I select character_maximum_length from INFORMATION_SCHEMA.COLUMNS if returns -1 on columns that are defined as varchar(max) is this normal???
8
by: Sham | last post by:
I am trying to perform the following query on a table that has been indexed using Full Text Search. The table contains multiple columns than have been indexed. (Below, all xml columns are...
2
by: amit2781 | last post by:
Hi, I have created 4 tables in 'amit' database and then I deleted them. Still I able to get information about the table_schema for the table deleted. After drop table when I fire a query for...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.