Book Image

PostgreSQL Developer's Guide

By : Ibrar Ahmed, Asif Fayyaz, Amjad Shahzad
Book Image

PostgreSQL Developer's Guide

By: Ibrar Ahmed, Asif Fayyaz, Amjad Shahzad

Overview of this book

<p>PostgreSQL is an enterprise-level database that competes among proprietary database vendors, owing to its remarkable feature set and reliability without the expensive licensing overhead.</p> <p>This book is a comprehensive and pragmatic guide to developing databases in PostgreSQL. Beginning with a refresher of basic SQL skills, you will gradually be exposed to advanced concepts, such as learning how to program in native PostgreSQL procedural languages, implementing triggers, custom functions, and views. You will learn database optimization techniques such as query optimization and indexing while exploring extensive code examples. Lastly, you will explore foreign data wrappers, implementing extensibility, and improving maintainability.</p>
Table of Contents (19 chapters)
PostgreSQL Developer's Guide
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Creating extensions


When creating an extension that is shipped to the PostgreSQL installer, users uses the CREATE EXTENSION command as follows:

CREATE EXTENSION [IF NOT EXISTS] extension_name
  [WITH] [SCHEMA schema_name]
  [Version]
  [FROM old_version]

When the user calls the CREATE EXTENSION command, it will load a specified extension into the current database. There must not be an extension of the same name already loaded. If an extension with the same name is already loaded, the user will get an error. In the backend, when the user calls the LOAD EXTENSION command, the extension script file will be executed. The script will create initial SQL objects that are mainly functions, data types, operators, and indexes. The CREATE EXTENSION command, in addition, notes down the identities of all the created objects so that they can be dropped again later, if the user executes the DROP EXTENSION command. Only superusers or users who have database owner privileges can create or drop an extension...