PostgreSQL 是一种非常复杂的对象-关系型数据库管理系统(ORDBMS),也是目前功能最强大,特性最丰富和最复杂的自由软件数据库系
一、简介
PostgreSQL 是一种非常复杂的对象-关系型数据库管理系统(ORDBMS),,也是目前功能最强大,特性最丰富和最复杂的自由软件数据库系统。有些特性甚至连商业数据库都不具备。这个起源于伯克利(BSD)的数据库研究计划目前已经衍生成一项国际开发项目,并且有非常广泛的用户。
二、系统环境
系统平台:CentOS release 6.3 (Final)
PostgreSQL 版本:PostgreSQL 9.2.4
防火墙已关闭/iptables: Firewall is not running.
SELINUX=disabled
三、安装方式
A. 下载RPM包安装
B. yum 安装
C. 源码包安装
四、安装过程
A. RPM包安装
1. 检查PostgreSQL 是否已经安装
[root@TS-DEV ~]# rpm -qa|grep postgres [root@TS-DEV ~]#若已经安装,则使用rpm -e 命令卸载。
2. 下载RPM包
#http:http:http://yum.postgresql.org/9.2/redhat/rhel-6-i386/postgresql92-9.2.4-1PGDG.rhel6.i686.rpm3. 安装PostgreSQL,注意安装顺序
# rpm -ivh postgresql92-libs-9.2.4-1PGDG.rhel6.i686.rpm# rpm -ivh postgresql92-9.2.4-1PGDG.rhel6.i686.rpm
# rpm -ivh postgresql92-server-9.2.4-1PGDG.rhel6.i686.rpm
# rpm -ivh postgresql92-contrib-9.2.4-1PGDG.rhel6.i686.rpm
4. 初始化PostgreSQL库
PostgreSQL 服务初次启动的时候会提示初始化。
5. 启动服务
# service postgresql-9.2 start6. 把PostgreSQL 服务加入到启动列表
# chkconfig postgresql # chkconfig --list|grep postgres7. 修改PostgreSQL数据库用户postgres的密码(注意不是linux系统帐号)
PostgreSQL数据库默认会创建一个postgres的数据库用户作为数据库的管理员,默认密码为空,我们需要修改为指定的密码,这里设定为’postgres’。
# su - postgres $ psql # ; # pg_shadow ;8. 测试数据库
8.1 创建测试数据库
# create database david;
8.2 切换到david 数据库
# \c david
8.3 创建测试表
david=# create table test ( id integer, name text);8.4 插入测试数据
david); david=#8.5 选择数据
david test ; id | name david (1 row) david=#测试成功。
更多详情见请继续阅读下一页的精彩内容:
相关阅读:
PostgreSQL删除表中重复数据行
PostgreSQL数据库连接池PgBouncer的搭建
Windows平台编译 PostgreSQL
PostgreSQL备份心得笔记
PostgreSQL 的详细介绍:请点这里
PostgreSQL 的下载地址:请点这里

MySQLstringtypesimpactstorageandperformanceasfollows:1)CHARisfixed-length,alwaysusingthesamestoragespace,whichcanbefasterbutlessspace-efficient.2)VARCHARisvariable-length,morespace-efficientbutpotentiallyslower.3)TEXTisforlargetext,storedoutsiderows,

MySQLstringtypesincludeVARCHAR,TEXT,CHAR,ENUM,andSET.1)VARCHARisversatileforvariable-lengthstringsuptoaspecifiedlimit.2)TEXTisidealforlargetextstoragewithoutadefinedlength.3)CHARisfixed-length,suitableforconsistentdatalikecodes.4)ENUMenforcesdatainte

MySQLoffersvariousstringdatatypes:1)CHARforfixed-lengthstrings,2)VARCHARforvariable-lengthtext,3)BINARYandVARBINARYforbinarydata,4)BLOBandTEXTforlargedata,and5)ENUMandSETforcontrolledinput.Eachtypehasspecificusesandperformancecharacteristics,sochoose

TograntpermissionstonewMySQLusers,followthesesteps:1)AccessMySQLasauserwithsufficientprivileges,2)CreateanewuserwiththeCREATEUSERcommand,3)UsetheGRANTcommandtospecifypermissionslikeSELECT,INSERT,UPDATE,orALLPRIVILEGESonspecificdatabasesortables,and4)

ToaddusersinMySQLeffectivelyandsecurely,followthesesteps:1)UsetheCREATEUSERstatementtoaddanewuser,specifyingthehostandastrongpassword.2)GrantnecessaryprivilegesusingtheGRANTstatement,adheringtotheprincipleofleastprivilege.3)Implementsecuritymeasuresl

ToaddanewuserwithcomplexpermissionsinMySQL,followthesesteps:1)CreatetheuserwithCREATEUSER'newuser'@'localhost'IDENTIFIEDBY'password';.2)Grantreadaccesstoalltablesin'mydatabase'withGRANTSELECTONmydatabase.TO'newuser'@'localhost';.3)Grantwriteaccessto'

The string data types in MySQL include CHAR, VARCHAR, BINARY, VARBINARY, BLOB, and TEXT. The collations determine the comparison and sorting of strings. 1.CHAR is suitable for fixed-length strings, VARCHAR is suitable for variable-length strings. 2.BINARY and VARBINARY are used for binary data, and BLOB and TEXT are used for large object data. 3. Sorting rules such as utf8mb4_unicode_ci ignores upper and lower case and is suitable for user names; utf8mb4_bin is case sensitive and is suitable for fields that require precise comparison.

The best MySQLVARCHAR column length selection should be based on data analysis, consider future growth, evaluate performance impacts, and character set requirements. 1) Analyze the data to determine typical lengths; 2) Reserve future expansion space; 3) Pay attention to the impact of large lengths on performance; 4) Consider the impact of character sets on storage. Through these steps, the efficiency and scalability of the database can be optimized.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

WebStorm Mac version
Useful JavaScript development tools

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

Zend Studio 13.0.1
Powerful PHP integrated development environment
