473,473 Members | 1,984 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

About table schema

Hi, does anyone know how to get the schema information
of a table. More specifically, I would like to know

1. which field(s) are primary keys?
2. the data type of each field of a table?
3. If a field is a foreign key, what field/table it
is referring to.

Thanks.

Wei

__________________________________
Do you Yahoo!?
Friends. Fun. Try the all-new Yahoo! Messenger.
http://messenger.yahoo.com/

---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match

Nov 23 '05 #1
6 1367
Am Mittwoch, 26. Mai 2004 00:36 schrieb Wei Shi:
Hi, does anyone know how to get the schema information
of a table. More specifically, I would like to know

1. which field(s) are primary keys?
2. the data type of each field of a table?
3. If a field is a foreign key, what field/table it
is referring to.


connect to your database with 'psql' and type

\d tablename

which gives you all information you asked for. Type \? for a list of other
commands within psql and take a look at 'man psql'

kind regards,
janning

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

Nov 23 '05 #2
Is there a function interface to get this information
other than from "psql" comman line interface?

Thanks.

Wei

--- Janning Vygen <vy***@gmx.de> wrote:
Am Mittwoch, 26. Mai 2004 00:36 schrieb Wei Shi:
Hi, does anyone know how to get the schema

information
of a table. More specifically, I would like to

know

1. which field(s) are primary keys?
2. the data type of each field of a table?
3. If a field is a foreign key, what field/table

it
is referring to.


connect to your database with 'psql' and type

\d tablename

which gives you all information you asked for. Type
\? for a list of other
commands within psql and take a look at 'man psql'

kind regards,
janning

---------------------------(end of
broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to

ma*******@postgresql.org

__________________________________
Do you Yahoo!?
Friends. Fun. Try the all-new Yahoo! Messenger.
http://messenger.yahoo.com/

---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match

Nov 23 '05 #3
Wei Shi wrote:
Is there a function interface to get this information
other than from "psql" comman line interface?


If you start psql with the '-E' switch, you'll see the queries it
generates to display the meta-data associated with the '\' command
you issue.

You may also query the tables and views in the information_schema
for what you want.

Mike Mascari
---------------------------(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 #4
This is great. Thanks.

Wei

--- Mike Mascari <ma*****@mascari.com> wrote:
Wei Shi wrote:
Is there a function interface to get this

information
other than from "psql" comman line interface?


If you start psql with the '-E' switch, you'll see
the queries it
generates to display the meta-data associated with
the '\' command
you issue.

You may also query the tables and views in the
information_schema
for what you want.

Mike Mascari
---------------------------(end of
broadcast)---------------------------
TIP 2: you can get off all lists at once with the
unregister command
(send "unregister YourEmailAddressHere" to

ma*******@postgresql.org)

__________________________________
Do you Yahoo!?
Friends. Fun. Try the all-new Yahoo! Messenger.
http://messenger.yahoo.com/

---------------------------(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 #5
Wei Shi wrote:
This is great. Thanks.


There is also the information schema in 7.4, e.g. "SELECT * FROM
information_schema.tables"

There's not as much detail there, but it's supposed to be standard
across different database systems.

--
Richard Huxton
Archonet Ltd

---------------------------(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 #6
Wei Shi wrote:
Hi, does anyone know how to get the schema information
of a table. More specifically, I would like to know

1. which field(s) are primary keys?
2. the data type of each field of a table?
3. If a field is a foreign key, what field/table it
is referring to.


Use the information schema views.
---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Nov 23 '05 #7

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

Similar topics

6
by: Jeff Kowalczyk | last post by:
I need to adapt this an update statement to a general form that will iterate over multiple orderids for a given customerinvoiceid. My first concern is a form that will work for a given orderid,...
5
by: Firehawk® | last post by:
Hi, I have a great experience with DB (Oracle and others) and I am using DB2 now. Then, I have few questions: 1. How drop a schema (user) and all objects of this schema, like a Oracle "drop...
6
by: CT | last post by:
Lets say you have a query select * from db2.employees; here what is db2 - is it schema name, database name or table creator name? Also, does it make a difference of notation when you are in...
10
by: BuddhaBuddy | last post by:
Platform is DB2/NT 7.2.9 The table was created like this: CREATE TABLE MYTEST ( MYTESTOID bigint not null primary key, FK_OTHEROID bigint not null references other, FK_ANOTHEROID bigint not...
1
by: felix-lists-pgsql | last post by:
I converted some tables from individual definitions to use object inheritance and now get failures of a foreign key constraint. Here is the file which creates schema tst and the tables: ...
7
by: slitvinov | last post by:
I am learning Relax NG. The problem is that I cannot figure out how to make a schema for a table. In my case I would like to make a table with any name of child elements (columns) but columns...
1
by: LurfysMa | last post by:
I am working on an electronic flashcard program. Most of the subjects are simple lists of questions and answers. Those seem to be working. Some of the "subjects" have "categories" of questions. ...
7
by: Serge Rielau | last post by:
Hi all, Following Ian's passionate postings on problems with ALTOBJ and the alter table wizard in the control center I'll try to explain how to use ALTOBJ with this thread. I'm not going to get...
3
by: Mike Husler | last post by:
We have a SQL Server database that can accept data from several different projects throughout our lab. Is it better to (1) let each developer create their own prepared SQL statements for inserts...
3
by: Michel Esber | last post by:
Hi all, Db2 v8 FP15 LUW . create table T (ID varchar (24), ABC timestamp) There is an index for (ID, ABC), allowing reverse Scans. My application needs to determine MIN and MAX(ABC) for a...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.