PostgreSQL

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


14


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.


15


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


16


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.


17


See Appendix В for a description of initdb,


18


Values less than this are reserved for internal use,


19


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


20


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


21


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,


22


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


23


   Create the sequence.


24


   Create the table, defining nextvalQ as the column default.


25


   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»