Скачать в pdf «PostgreSQL»


A table cannot be called order. The word order is a reserved keyword, for use in the ORDER by clause. Reserved keywords are not available as table or column names.


The United States Postal Service has assigned a unique two-letter code to each U.S. state.


In our example, changing part.price would change the price on previous orders of the part, which would cause problems. In the real world, we would need apartprice table to store the part number, price, and effective date for the price.


See Appendix В for a description of initdb,


Values less than this are reserved for internal use,


technically, OID’s are unique among all databases sharing a common /data directory tree,


Several other invisible columns exist as well. The PostgreSQL manuals cover their meaning and use.


This is not completely accurate. Gaps can occur if a query is assigned a sequence number as part of an aborted transaction. See Section 10,2 for a description of aborted transactions,


Tables can be configured to share sequence counters, if desired,


   Create the sequence.


   Create the table, defining nextvalQ as the column default.


   During the insert, do not supply a value for the sequenced column, or use nextvalQ.

Figure 7.4 shows the use of a sequence for unique row numbering in the customer table. The first statement creates a sequence counter named customer_seq. The second command creates the customer table, and defines nextval(’customer_seq’} as the default for the customerjd column. The first insert manually supplies the sequence value for the column. The nextval(’customer_-seq’} function call will return the next available sequence number, and increment the sequence counter. The second and third inserts allow the nextval(’customer_seq’} default to be used for the customerjd column. Remember, a column’s default value is used only when a value is not supplied by an insert statement. (This is covered in Section 4.4.) The select shows that the customer rows have been sequentially numbered.

Скачать в pdf «PostgreSQL»