ITPub博客

首页 > 数据库 > PostgreSQL > PostgreSQL DBA(105) - pgAdmin(Don't do this:psql&inheritance)

PostgreSQL DBA(105) - pgAdmin(Don't do this:psql&inheritance)

翻译 PostgreSQL 作者:husthxd 时间:2019-10-12 11:44:16 0 删除 编辑

no zuo no die系列,来自于pg的wiki。

这是第三部分,包括psql登录时无需带-W/—password参数以及不要使用继承表(inheritance)。
一、psql不带-W
原因是:

Using the —password or -W flags will tell psql to prompt you for a password, before trying to connect to the server - so you’ll be prompted for a password even if the server doesn’t require one.
It’s never required, as if the server does require a password psql will prompt you for one, and it can be very confusing when setting up permissions. If you’re connecting with -W to a server configured to allow you access via peer authentication you may think that it’s requiring a password when it really isn’t. And if the user you’re logging in as doesn’t have a password set or you enter the wrong password at the prompt you’ll still be logged in and think you have the right password - but you won’t be able to log in from other clients (that connect via localhost) or when logged in as other users.
简单来说就是,不需要密码的,带了该参数,无论输入什么或者不输入都可以登录;而需要密码时,带不带该参数都会提示输入密码。
```
pg12 @localhost ~]$ psql -d testdb -W
Password: —> 不输入密码,直接回车也可以登录
Timing is on.
Expanded display is used automatically.
psql (12.0)
Type “help” for help.

[local]:5432 pg12 @testdb=#
```

二、不使用继承表
原因是:

Table inheritance was a part of a fad wherein the database was closely coupled to object-oriented code. It turned out that coupling things that closely didn’t actually produce the desired results.
继承表的设计目的是为了使用面向对象的设计方法,但对于RDBMS的数据库而非OO数据库,使用继承并没有必要,反而增加复杂度和理解的难度。

参考资料
Don’t Do This

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/6906/viewspace-2659665/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
ITPUB数据库版块资深版主,对Oracle、PostgreSQL有深入研究。

注册时间:2007-12-28

  • 博文量
    1416
  • 访问量
    3855848