postgresql-8.3-A4 - PostgreSQL 8.3.9 Documentation The PostgreSQL Global Development Group PostgreSQL 8.3.9 Documentation by The PostgreSQL Global

postgresql-8.3-A4 - PostgreSQL 8.3.9 Documentation The...

This preview shows page 1 out of 1965 pages.

You've reached the end of your free preview.

Want to read all 1965 pages?

Unformatted text preview: PostgreSQL 8.3.9 Documentation The PostgreSQL Global Development Group PostgreSQL 8.3.9 Documentation by The PostgreSQL Global Development Group Copyright © 1996-2008 The PostgreSQL Global Development Group Legal Notice PostgreSQL is Copyright © 1996-2008 by the PostgreSQL Global Development Group and is distributed under the terms of the license of the University of California below. Postgres95 is Copyright © 1994-5 by the Regents of the University of California. Permission to use, copy, modify, and distribute this software and its documentation for any purpose, without fee, and without a written agreement is hereby granted, provided that the above copyright notice and this paragraph and the following two paragraphs appear in all copies. IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN “AS-IS” BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. Table of Contents Preface ..............................................................................................................................................xlii 1. What is PostgreSQL? ...........................................................................................................xlii 2. A Brief History of PostgreSQL...........................................................................................xliii 2.1. The Berkeley POSTGRES Project .........................................................................xliii 2.2. Postgres95...............................................................................................................xliii 2.3. PostgreSQL.............................................................................................................xliv 3. Conventions.........................................................................................................................xliv 4. Further Information.............................................................................................................. xlv 5. Bug Reporting Guidelines.................................................................................................... xlv 5.1. Identifying Bugs .....................................................................................................xlvi 5.2. What to report.........................................................................................................xlvi 5.3. Where to report bugs ............................................................................................xlviii I. Tutorial............................................................................................................................................. 1 1. Getting Started ........................................................................................................................ 1 1.1. Installation .................................................................................................................. 1 1.2. Architectural Fundamentals........................................................................................ 1 1.3. Creating a Database.................................................................................................... 2 1.4. Accessing a Database ................................................................................................. 3 2. The SQL Language ................................................................................................................. 6 2.1. Introduction ................................................................................................................ 6 2.2. Concepts ..................................................................................................................... 6 2.3. Creating a New Table ................................................................................................. 6 2.4. Populating a Table With Rows ................................................................................... 7 2.5. Querying a Table ........................................................................................................ 8 2.6. Joins Between Tables................................................................................................ 10 2.7. Aggregate Functions................................................................................................. 12 2.8. Updates ..................................................................................................................... 13 2.9. Deletions................................................................................................................... 14 3. Advanced Features ................................................................................................................ 15 3.1. Introduction .............................................................................................................. 15 3.2. Views ........................................................................................................................ 15 3.3. Foreign Keys............................................................................................................. 15 3.4. Transactions.............................................................................................................. 16 3.5. Inheritance ................................................................................................................ 18 3.6. Conclusion................................................................................................................ 19 II. The SQL Language...................................................................................................................... 21 4. SQL Syntax ........................................................................................................................... 23 4.1. Lexical Structure....................................................................................................... 23 4.1.1. Identifiers and Key Words............................................................................ 23 4.1.2. Constants...................................................................................................... 24 4.1.2.1. String Constants .............................................................................. 24 4.1.2.2. Dollar-Quoted String Constants ...................................................... 25 4.1.2.3. Bit-String Constants ........................................................................ 26 4.1.2.4. Numeric Constants .......................................................................... 26 4.1.2.5. Constants of Other Types ................................................................ 27 4.1.3. Operators...................................................................................................... 28 4.1.4. Special Characters........................................................................................ 28 4.1.5. Comments .................................................................................................... 29 iii 4.1.6. Lexical Precedence ...................................................................................... 29 4.2. Value Expressions..................................................................................................... 30 4.2.1. Column References...................................................................................... 31 4.2.2. Positional Parameters................................................................................... 31 4.2.3. Subscripts..................................................................................................... 32 4.2.4. Field Selection ............................................................................................. 32 4.2.5. Operator Invocations.................................................................................... 33 4.2.6. Function Calls .............................................................................................. 33 4.2.7. Aggregate Expressions................................................................................. 33 4.2.8. Type Casts .................................................................................................... 34 4.2.9. Scalar Subqueries......................................................................................... 35 4.2.10. Array Constructors..................................................................................... 35 4.2.11. Row Constructors....................................................................................... 36 4.2.12. Expression Evaluation Rules ..................................................................... 38 5. Data Definition ...................................................................................................................... 39 5.1. Table Basics.............................................................................................................. 39 5.2. Default Values .......................................................................................................... 40 5.3. Constraints................................................................................................................ 41 5.3.1. Check Constraints ........................................................................................ 41 5.3.2. Not-Null Constraints.................................................................................... 43 5.3.3. Unique Constraints....................................................................................... 44 5.3.4. Primary Keys................................................................................................ 44 5.3.5. Foreign Keys ................................................................................................ 45 5.4. System Columns....................................................................................................... 48 5.5. Modifying Tables...................................................................................................... 49 5.5.1. Adding a Column......................................................................................... 49 5.5.2. Removing a Column .................................................................................... 50 5.5.3. Adding a Constraint ..................................................................................... 50 5.5.4. Removing a Constraint ................................................................................ 51 5.5.5. Changing a Column’s Default Value............................................................ 51 5.5.6. Changing a Column’s Data Type ................................................................. 51 5.5.7. Renaming a Column .................................................................................... 52 5.5.8. Renaming a Table ........................................................................................ 52 5.6. Privileges .................................................................................................................. 52 5.7. Schemas.................................................................................................................... 53 5.7.1. Creating a Schema ....................................................................................... 53 5.7.2. The Public Schema ...................................................................................... 54 5.7.3. The Schema Search Path.............................................................................. 54 5.7.4. Schemas and Privileges................................................................................ 56 5.7.5. The System Catalog Schema ....................................................................... 56 5.7.6. Usage Patterns.............................................................................................. 56 5.7.7. Portability..................................................................................................... 57 5.8. Inheritance ................................................................................................................ 57 5.8.1. Caveats ......................................................................................................... 60 5.9. Partitioning ............................................................................................................... 60 5.9.1. Overview...................................................................................................... 60 5.9.2. Implementing Partitioning ........................................................................... 61 5.9.3. Managing Partitions ..................................................................................... 64 5.9.4. Partitioning and Constraint Exclusion ......................................................... 65 5.9.5. Alternative Partitioning Methods................................................................. 66 5.9.6. Caveats ......................................................................................................... 66 5.10. Other Database Objects .......................................................................................... 67 iv 5.11. Dependency Tracking............................................................................................. 68 6. Data Manipulation................................................................................................................. 69 6.1. Inserting Data ........................................................................................................... 69 6.2. Updating Data........................................................................................................... 70 6.3. Deleting Data............................................................................................................ 71 7. Queries .................................................................................................................................. 72 7.1. Overview .................................................................................................................. 72 7.2. Table Expressions ..................................................................................................... 72 7.2.1. The FROM Clause.......................................................................................... 73 7.2.1.1. Joined Tables ................................................................................... 73 7.2.1.2. Table and Column Aliases............................................................... 76 7.2.1.3. Subqueries ....................................................................................... 77 7.2.1.4. Table Functions ............................................................................... 77 7.2.2. The WHERE Clause........................................................................................ 78 7.2.3. The GROUP BY and HAVING Clauses........................................................... 79 7.3. Select Lists................................................................................................................ 81 7.3.1. Select-List Items .......................................................................................... 82 7.3.2. Column Labels ............................................................................................. 82 7.3.3. DISTINCT .................................................................................................... 83 7.4. Combining Queries................................................................................................... 83 7.5. Sorting Rows ............................................................................................................ 84 7.6. LIMIT and OFFSET................................................................................................... 85 7.7. VALUES Lists ............................................................................................................ 85 8. Data Types............................................................................................................................. 87 8.1. Numeric Types.......................................................................................................... 88 8.1.1. Integer Types................................................................................................ 89 8.1.2. Arbitrary Precision Numbers ....................................................................... 89 8.1.3. Floating-Point Types .................................................................................... 90 8.1.4. Serial Types.................................................................................................. 91 8.2. Monetary Types ........................................................................................................ 92 8.3. Character Types ........................................................................................................ 93 8.4. Binary Data Types .................................................................................................... 95 8.5. Date/Time Types....................................................................................................... 96 8.5.1. Date/Time Input ........................................................................................... 97 8.5.1.1. Dates................................................................................................ 98 8.5.1.2. Times ............................................................................................... 98 8.5.1.3. Time Stamps.................................................................................... 99 8.5.1.4. Intervals ......................................................................................... 100 8.5.1.5. Special Values ............................................................................... 101 8.5.2. Date/Time Output ...................................................................................... 101 8.5.3. Time Zones ................................................................................................ 102 8.5.4. Internals...................................................................................................... 104 8.6. Boolean Type.......................................................................................................... 104 8.7. Enumerated Types .................................................................................................. 105 8.7.1. Declaration of Enumerated Types.............................................................. 105 8.7.2. Ordering ..................................................................................................... 105 8.7.3. Type Safety ................................................................................................ 106 8.7.4. Implementation Details.............................................................................. 107 8.8. Geometric Types..................................................................................................... 107 8.8.1. Points ......................................................................................................... 107 8.8.2. Line Segments............................................................................................ 108 8.8.3. Boxes...............................................
View Full Document

  • Summer '16
  • ahmaid
  • The Land, ........., Regular expression

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture