Полезная информация

next up previous contents index
Next: Comments Up: Customizing Queries Previous: Column Labels

Data types

 Table [*] shows the most common column data types.

 
Table: Common data types
Category Type Description
character string char(length) blank-padded string, fixed storage length
  varchar(length) non-blank-padded string, variable storage length
number integer -2 billion to 2 billion integer, 4-byte storage
  float double-precision floating point number, 8-byte storage
  numeric(precision, decimal) arbitrary precision number
date/time date date
  time time
  datetime date and time


Figure [*] shows queries using these types. There is table creation, INSERT, and SELECT.
  
Figure: Example of common data types
\begin{figure}\begin{list}{}{
\setlength{\rightmargin}{\leftmargin}
\raggedrigh...
...\\
00\vert Wed~Jul~03~10:30:00~1996~EDT
\par (1~row)\end{list}\par
\end{figure}

There are a few things of interest in this example. First, notice how the numbers did not require quotes, while character strings, dates, and times require them. Also note the datetime column displays its value in the standard UNIX date6.3 format. It also keeps track of the time zone. Finally, notice the last SELECT query. When you select too much information to fit on one line, the display wraps around, making it hard to read. The columns still line up, but there is other data in the way. There is no good solution to this except selecting fewer columns or using psql's expanded output option, \x, which displays one field per line.6.4 You can select any columns from the table in any order.


next up previous contents index
Next: Comments Up: Customizing Queries Previous: Column Labels
Bruce Momjian
1999-11-21