Install and use PostgreSQL extension modules

Source: Internet
Author: User

In this article, we will learn how to install and use the PostgreSQL module, includingChkpass,Fuzzystrmatch,IsnAndHstoreThe. 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 installPostgresql-contribPackage and restart the database server, and then checkContribCheck whether the directory contains some available modules:

 
1 sudo apt-get install postgresql-contrib
2 sudo /etc/init.d/postgresql-8.4 restart
3 cd /usr/share/postgresql/8.4/contrib/
4 ls

Then we create a database named module_test:

 
1 su postgres
2 createdb module_test

Then we set the moduleChkpass,Fuzzystrmatch,IsnAndHstoreApplyModule_testDatabase:

 
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

ChkpassThe 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'

Where=Operator UsedEq (column_name, text)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 relatively 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.

  • 1
  • 2
  • Next Page

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.