Install and use PostgreSQL extension modules

Source: Internet
Author: User
In this article, we will learn how to install and use PostgreSQL modules, including chkpass, fuzzystrmatch, isn, and hstore.

In this article, we will learn how to install and use PostgreSQL modules, including chkpass, fuzzystrmatch, isn, and hstore.

In this article, we will learn how to install and use PostgreSQL modules, including chkpass, fuzzystrmatch, isn, and hstore. the module adds different functions to the database, such as management and monitoring tools, new data types, operators, functions and algorithms. We will test the modules that add data types and algorithms. These modules allow the database to have the application logic.

PostgreSQL is called "the most advanced open source database". I have been in foodlets for the past four years. use it on in, and store space data on CSTEP (Center for Study of Science, Technology and Policy. PostgreSQL is a database that won't disappoint me.

Installation Module

Note: My runtime environments are Ubuntu 10.04 and PostgreSQL 8.4.

First, install the postgresql-contrib package and restart the database server. Then, check the contrib directory to see if there are some available modules:

1 sudo apt-get install postgresql-contrib

2 sudo/etc/init. d/postgresql-8.4 restart

3cd/usr/share/postgresql/8.4/contrib/

4ls

Then we create a database named module_test:

1su ipvs

2 createdb module_test

Then we apply chkpass, fuzzystrmatch, isn, and hstore modules to the module_test database and execute the following command:

1 psql-d module_test-f chkpass. SQL

2 psql-d module_test-f fuzzystrmatch. SQL

3 psql-d module_test-f isn. SQL

4 psql-d module_test-f hstore. SQL

Next, let's take a look at how each module is used.

Use chkpass

The chkpass module introduces a new data type "chkpass" to store an encrypted field, such as a password. You can see from the SQL below that the string stored in the chkpass field is automatically encrypted:

1 create table accounts (username varchar (100), password chkpass );

2 insert into accounts (username, "password") VALUES ('user1', 'pass1 ');

3 insert into accounts (username, "password") VALUES ('user2', 'pass2 ');

Then we can perform identity authentication through the following SQL:

1 SELECT count (*) from accounts where username = 'user1' and password = 'pass1'

The = operator uses the eq (column_name, text) method. This method is provided by the chkpass module to test whether it is equal. Chkpass uses the Unix crypt () function, so the encryption effect is weak. This function only encrypts the first eight digits of the string, as long as the first eight digits of the same string are considered to be equal. Therefore, it is not recommended to use the chkpass module in the actual production environment. We recommend that you use the pgcrypto module.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.