SlideShare une entreprise Scribd logo
1  sur  7
Télécharger pour lire hors ligne
15	
  PracNcal	
  PostgreSQL	
  Database	
  AdministraNon	
  Commands                                                                               hTp://www.thegeekstuff.com/2009/04/15-­‐pracNcal-­‐postgresql...




                           Home
                           About
                           Free	
  eBook
                           Archives
                           Best	
  of	
  the	
  Blog
                           Contact


               15	
  Prac(cal	
  PostgreSQL	
  Database	
  Administra(on	
  Commands
               by	
  Ramesh	
  Natarajan	
  on	
  April	
  16,	
  2009

                              15                       Like     7               Tweet         16



               Earlier	
  we	
  discussed	
  about	
  how	
  to	
  install	
  PostgreSQL	
  database	
  on	
  Linux	
  from	
  source.

               In	
  this	
  arNcle,	
  let	
  us	
  review	
  top	
  15	
  pracNcal	
  postgreSQL	
  DBA	
  command	
  examples.

               If	
  you	
  are	
  a	
  mySQL	
  administrator,	
  check-­‐out	
  our	
  15	
  examples	
  of	
  mysqladmin	
  command	
  arNcle	
  that
               we	
  discussed	
  a	
  while	
  back.




               1.	
  How	
  to	
  change	
  PostgreSQL	
  root	
  user	
  password	
  ?

               $ /usr/local/pgsql/bin/psql postgres postgres
               Password: (oldpassword)
               # ALTER USER postgres WITH PASSWORD 'tmppassword';

               $ /usr/local/pgsql/bin/psql postgres postgres
               Password: (tmppassword)


               Changing	
  the	
  password	
  for	
  a	
  normal	
  postgres	
  user	
  is	
  similar	
  as	
  changing	
  the	
  password	
  of	
  the	
  root	
  user.	
  Root	
  user	
  can	
  change	
  the	
  password	
  of	
  any	
  user,	
  and	
  the
               normal	
  users	
  can	
  only	
  change	
  their	
  passwords	
  as	
  Unix	
  way	
  of	
  doing.

               # ALTER USER username WITH PASSWORD 'tmppassword';

               2.	
  How	
  to	
  setup	
  PostgreSQL	
  SysV	
  startup	
  script?

               $ su - root

               # tar xvfz postgresql-8.3.7.tar.gz

               # cd postgresql-8.3.7

               # cp contrib/start-scripts/linux /etc/rc.d/init.d/postgresql

               # chmod a+x /etc/rc.d/init.d/postgresql

               3.	
  How	
  to	
  check	
  whether	
  PostgreSQL	
  server	
  is	
  up	
  and	
  running?

               $ /etc/init.d/postgresql status
               Password:
               pg_ctl: server is running (PID: 6171)
               /usr/local/pgsql/bin/postgres "-D" "/usr/local/pgsql/data"
               [Note: The status above indicates the server is up and running]




1	
  of	
  7                                                                                                                                                                                                                                    18	
  Apr	
  12	
  7:18	
  pm
15	
  PracNcal	
  PostgreSQL	
  Database	
  AdministraNon	
  Commands                                                         hTp://www.thegeekstuff.com/2009/04/15-­‐pracNcal-­‐postgresql...



               $ /etc/init.d/postgresql status
               Password:
               pg_ctl: no server running
               [Note: The status above indicates the server is down]

               4.	
  How	
  to	
  start,	
  stop	
  and	
  restart	
  PostgreSQL	
  database?

               # service postgresql stop
               Stopping PostgreSQL: server stopped
               ok

               # service postgresql start
               Starting PostgreSQL: ok

               # service postgresql restart
               Restarting PostgreSQL: server stopped
               ok

               5.	
  How	
  do	
  I	
  find	
  out	
  what	
  version	
  of	
  PostgreSQL	
  I	
  am	
  running?

               $ /usr/local/pgsql/bin/psql test
               Welcome to psql 8.3.7, the PostgreSQL interactive terminal.

               Type: copyright for distribution terms
               h for help with SQL commands
               ? for help with psql commands
               g or terminate with semicolon to execute query
               q to quit

               test=# select version();
               version
               ----------------------------------------------------------------------------------------------------
               PostgreSQL 8.3.7 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 4.1.2 20071124 (Red Hat 4.1.2-42)
               (1 row)

               test=#

               5.	
  How	
  to	
  create	
  a	
  PostgreSQL	
  user	
  ?

               There	
  are	
  two	
  methods	
  in	
  which	
  you	
  can	
  create	
  user.

               Method	
  1:	
  CreaNng	
  the	
  user	
  in	
  the	
  PSQL	
  prompt,	
  with	
  CREATE	
  USER	
  command.

               # CREATE USER ramesh WITH password 'tmppassword';
               CREATE ROLE

               Method	
  2:	
  CreaNng	
  the	
  user	
  in	
  the	
  shell	
  prompt,	
  with	
  createuser	
  command.

               $ /usr/local/pgsql/bin/createuser sathiya
               Shall the new role be a superuser? (y/n) n
               Shall the new role be allowed to create databases? (y/n) n
               Shall the new role be allowed to create more new roles? (y/n) n
               CREATE ROLE

               6.	
  How	
  to	
  create	
  a	
  PostgreSQL	
  Database	
  ?

               There	
  are	
  two	
  metods	
  in	
  which	
  you	
  can	
  create	
  two	
  databases.

               Method	
  1:	
  CreaNng	
  the	
  database	
  in	
  the	
  PSQL	
  prompt,	
  with	
  createuser	
  command.

               # CREATE DATABASE mydb WITH OWNER ramesh;
               CREATE DATABASE

               Method	
  2:	
  CreaNng	
  the	
  database	
  in	
  the	
  shell	
  prompt,	
  with	
  createdb	
  command.

               $ /usr/local/pgsql/bin/createdb mydb -O ramesh
               CREATE DATABASE

               *	
  -­‐O	
  owner	
  name	
  is	
  the	
  opNon	
  in	
  the	
  command	
  line.




2	
  of	
  7                                                                                                                                                               18	
  Apr	
  12	
  7:18	
  pm
15	
  PracNcal	
  PostgreSQL	
  Database	
  AdministraNon	
  Commands                                                                                           hTp://www.thegeekstuff.com/2009/04/15-­‐pracNcal-­‐postgresql...


               7.	
  How	
  do	
  I	
  get	
  a	
  list	
  of	
  databases	
  in	
  a	
  Postgresql	
  database	
  ?

               # l [Note: This is backslash followed by lower-case L]
               List of databases
               Name | Owner | Encoding
               ----------+----------+----------
               backup | postgres | UTF8
               mydb | ramesh | UTF8
               postgres | postgres | UTF8
               template0 | postgres | UTF8
               template1 | postgres | UTF8

               8.	
  How	
  to	
  Delete/Drop	
  an	
  exis(ng	
  PostgreSQL	
  database	
  ?

               # l
               List of databases
               Name | Owner | Encoding
               ----------+----------+----------
               backup | postgres | UTF8
               mydb | ramesh | UTF8
               postgres | postgres | UTF8
               template0 | postgres | UTF8
               template1 | postgres | UTF8

               # DROP DATABASE mydb;
               DROP DATABASE

               9.	
  GeWng	
  help	
  on	
  postgreSQL	
  commands

               ?	
  will	
  show	
  PSQL	
  command	
  prompt	
  help.	
  h	
  CREATE	
  will	
  shows	
  help	
  about	
  all	
  the	
  commands	
  that	
  starts	
  with	
  CREATE,	
  when	
  you	
  want	
  something	
  specific	
  such
               as	
  help	
  for	
  creaNng	
  index,	
  then	
  you	
  need	
  to	
  give	
  CREATE	
  INDEX.

               # ?

               # h CREATE

               # h CREATE INDEX

               10.	
  How	
  do	
  I	
  get	
  a	
  list	
  of	
  all	
  the	
  tables	
  in	
  a	
  Postgresql	
  database?

               # d

               On	
  an	
  empty	
  database,	
  you’ll	
  get	
  “No	
  relaNons	
  found.”	
  message	
  for	
  the	
  above	
  command.

               11.	
  How	
  to	
  turn	
  on	
  (ming,	
  and	
  checking	
  how	
  much	
  (me	
  a	
  query	
  takes	
  to	
  execute	
  ?

               #	
  Nming	
  —	
  Ager	
  this	
  if	
  you	
  execute	
  a	
  query	
  it	
  will	
  show	
  how	
  much	
  Nme	
  it	
  took	
  for	
  doing	
  it.

               # timing
               Timing is on.

               # SELECT * from pg_catalog.pg_attribute ;
               Time: 9.583 ms

               12.	
  How	
  To	
  Backup	
  and	
  Restore	
  PostgreSQL	
  Database	
  and	
  Table?

               We	
  discussed	
  earlier	
  how	
  to	
  backup	
  and	
  restore	
  postgres	
  database	
  and	
  tables	
  using	
  pg_dump	
  and	
  psql	
  uNlity.

               13.	
  How	
  to	
  see	
  the	
  list	
  of	
  available	
  func(ons	
  in	
  PostgreSQL	
  ?

               To	
  get	
  to	
  know	
  more	
  about	
  the	
  funcNons,	
  say	
  df+

               # df

               # df+

               14.	
  How	
  to	
  edit	
  PostgreSQL	
  queries	
  in	
  your	
  favorite	
  editor	
  ?

               # e



3	
  of	
  7                                                                                                                                                                                                                     18	
  Apr	
  12	
  7:18	
  pm
15	
  PracNcal	
  PostgreSQL	
  Database	
  AdministraNon	
  Commands                                                                                        hTp://www.thegeekstuff.com/2009/04/15-­‐pracNcal-­‐postgresql...


               e	
  will	
  open	
  the	
  editor,	
  where	
  you	
  can	
  edit	
  the	
  queries	
  and	
  save	
  it.	
  By	
  doing	
  so	
  the	
  query	
  will	
  get	
  executed.

               15.	
  Where	
  can	
  i	
  find	
  the	
  postgreSQL	
  history	
  file	
  ?

               Similar	
  to	
  the	
  Linux	
  ~/.bash_history	
  file,	
  postgreSQL	
  stores	
  all	
  the	
  sql	
  command	
  that	
  was	
  executed	
  in	
  a	
  history	
  filed	
  called	
  ~/.psql_history	
  as	
  shown	
  below.

               $ cat ~/.psql_history
               alter user postgres with password 'tmppassword';
               h alter user
               select version();
               create user ramesh with password 'tmppassword';
               timing
               select * from pg_catalog.pg_attribute;



                                15                    Tweet             16                   Like      7               	
  Share               	
  Comment


               If	
  you	
  enjoyed	
  this	
  ar(cle,	
  you	
  might	
  also	
  like..


                       1.    50	
  Linux	
  Sysadmin	
  Tutorials                                                                                   Awk	
  IntroducNon	
  –	
  7	
  Awk	
  Print	
  Examples
                       2.    50	
  Most	
  Frequently	
  Used	
  Linux	
  Commands	
  (With	
  Examples)                                            Advanced	
  Sed	
  SubsNtuNon	
  Examples
                       3.    Top	
  25	
  Best	
  Linux	
  Performance	
  Monitoring	
  and	
  Debugging	
  Tools                                   8	
  EssenNal	
  Vim	
  Editor	
  NavigaNon	
  Fundamentals
                       4.    Mommy,	
  I	
  found	
  it!	
  –	
  15	
  PracNcal	
  Linux	
  Find	
  Command	
  Examples                             25	
  Most	
  Frequently	
  Used	
  Linux	
  IPTables	
  Rules	
  Examples
                       5. Linux	
  101	
  Hacks	
  2nd	
  EdiNon	
  eBook	
                                                                         Turbocharge	
  PuTTY	
  with	
  12	
  Powerful	
  Add-­‐Ons




               Tags:	
  Change	
  Postgres	
  Password,	
  IdenNfy	
  PostgreSQL	
  Version,	
  Postgres,	
  PostgreSQL	
  database,	
  PostgreSQL	
  DB,	
  PostgreSQL	
  DBA	
  Commands,	
  PostgreSQL	
  psql
               command,	
  Start	
  and	
  Stop	
  PostgreSQL	
  Database,	
  ~/.psql_history

               {	
  6	
  comments…	
  read	
  them	
  below	
  or	
  add	
  one	
  }

               1	
  sasikala	
  April	
  16,	
  2009	
  at	
  10:20	
  pm

                            It	
  is	
  very	
  simple	
  but	
  more	
  useful.	
  thanks.

               2	
  mike	
  March	
  21,	
  2010	
  at	
  10:41	
  pm

                            very	
  useful	
  for	
  beginners	
  like	
  me.	
  Thanks.

               3	
  karel	
  April	
  28,	
  2010	
  at	
  2:59	
  am

                            ager	
  using
                            d
                            i	
  get	
  list	
  of	
  the	
  tables	
  ,and	
  highlighted
                            (END)

                            i	
  cannot	
  enter	
  any	
  text	
  or	
  command.	
  How	
  to	
  exit	
  the	
  descripNon	
  and	
  input	
  next	
  commands?

               4	
  markitus82	
  May	
  18,	
  2010	
  at	
  10:03	
  am

                            thanks!	
  nice	
  guide!




4	
  of	
  7                                                                                                                                                                                                                           18	
  Apr	
  12	
  7:18	
  pm
15	
  PracNcal	
  PostgreSQL	
  Database	
  AdministraNon	
  Commands                                                                                          hTp://www.thegeekstuff.com/2009/04/15-­‐pracNcal-­‐postgresql...


               5	
  NR	
  August	
  11,	
  2010	
  at	
  8:54	
  pm

                            Some	
  clarificaNons:
                            d	
  gaves	
  you	
  more	
  then	
  just	
  tables,	
  to	
  see	
  only	
  tables	
  use	
  dt.	
  To	
  see	
  views	
  use	
  dv,	
  to	
  see	
  a	
  table	
  or	
  any	
  other	
  object’s	
  descripNon	
  use	
  d	
  objectname.
                            You	
  can	
  use	
  ?	
  to	
  see	
  a	
  list	
  of	
  commands	
  and	
  ?	
  commandname	
  to	
  get	
  help	
  with	
  a	
  command.	
  The	
  same	
  way	
  you	
  can	
  use	
  h	
  to	
  see	
  a	
  list	
  of	
  SQL
                            commands	
  and	
  h	
  sqlcommand	
  to	
  get	
  help	
  with	
  a	
  SQL	
  command.

                            Be	
  aware	
  that	
  a	
  simple	
  create	
  database	
  command	
  will	
  create	
  a	
  database	
  with	
  default	
  parameters,	
  this	
  is	
  not	
  always	
  what	
  we	
  want	
  or	
  need.	
  Usually	
  it	
  is
                            ok	
  for	
  english	
  speakers	
  but	
  other	
  languages	
  migth	
  need	
  a	
  different	
  collaNng	
  order	
  or	
  even	
  encoding,	
  as	
  the	
  default	
  postgresql	
  installaNon	
  does	
  not	
  (or
                            did	
  not)	
  use	
  UTF-­‐8.	
  To	
  change	
  this	
  and	
  other	
  parameters	
  in	
  a	
  safe	
  and	
  permanent	
  way	
  you	
  migth	
  need	
  to	
  create	
  a	
  all	
  new	
  database	
  cluster	
  as	
  some
                            parameters	
  cannot	
  be	
  changed	
  ager	
  database	
  creaNon	
  and	
  others	
  have	
  to	
  be	
  common	
  to	
  all	
  databases	
  (see	
  hTp://www.postgresql.org/docs/8.4
                            /interacNve/locale.html	
  for	
  postgreSQL	
  8.4).

                            Has	
  for	
  the	
  Karel’s	
  problem,	
  simply	
  use	
  ‘q’	
  to	
  quit	
  the	
  viewing	
  and	
  came	
  back	
  to	
  the	
  prompt.

               6	
  Anonymous	
  September	
  20,	
  2011	
  at	
  11:50	
  pm

                            this	
  is	
  very	
  useful	
  for	
  me

               Leave	
  a	
  Comment

                                                                                                   Name


                                                                                                   E-­‐mail


                                                                                                   Website




                     	
  NoNfy	
  me	
  of	
  followup	
  comments	
  via	
  e-­‐mail

                   Submit

               Previous	
  post:	
  Open	
  &	
  View	
  10	
  Different	
  File	
  Types	
  with	
  Linux	
  Less	
  Command	
  –	
  The	
  UlNmate	
  Power	
  of	
  Less

               Next	
  post:	
  Ctags	
  and	
  Taglist:	
  Convert	
  Vim	
  Editor	
  to	
  BeauNful	
  Source	
  Code	
  Browser	
  for	
  Any	
  Programming	
  Language

                            Sign	
  up	
  for	
  our	
  free	
  email	
  newsleTer	
   you@address.com                                                   	
  	
  	
  	
  	
     Sign Up


                                                          	
  	
  	
  	
  	
     	
  RSS	
     	
  TwiTer	
     	
  Facebook



                                                                                                                               	
     Search

                            EBOOKS




5	
  of	
  7                                                                                                                                                                                                                                                18	
  Apr	
  12	
  7:18	
  pm
15	
  PracNcal	
  PostgreSQL	
  Database	
  AdministraNon	
  Commands                                                      hTp://www.thegeekstuff.com/2009/04/15-­‐pracNcal-­‐postgresql...




                  POPULAR	
  POSTS

                         12	
  Amazing	
  and	
  EssenNal	
  Linux	
  Books	
  To	
  Enrich	
  Your	
  Brain	
  and	
  Library
                         50	
  UNIX	
  /	
  Linux	
  Sysadmin	
  Tutorials
                         50	
  Most	
  Frequently	
  Used	
  UNIX	
  /	
  Linux	
  Commands	
  (With	
  Examples)
                         How	
  To	
  Be	
  ProducNve	
  and	
  Get	
  Things	
  Done	
  Using	
  GTD
                         30	
  Things	
  To	
  Do	
  When	
  you	
  are	
  Bored	
  and	
  have	
  a	
  Computer
                         Linux	
  Directory	
  Structure	
  (File	
  System	
  Structure)	
  Explained	
  with	
  Examples
                         Linux	
  Crontab:	
  15	
  Awesome	
  Cron	
  Job	
  Examples
                         Get	
  a	
  Grip	
  on	
  the	
  Grep!	
  –	
  15	
  PracNcal	
  Grep	
  Command	
  Examples
                         Unix	
  LS	
  Command:	
  15	
  PracNcal	
  Examples
                         15	
  Examples	
  To	
  Master	
  Linux	
  Command	
  Line	
  History
                         Top	
  10	
  Open	
  Source	
  Bug	
  Tracking	
  System
                         Vi	
  and	
  Vim	
  Macro	
  Tutorial:	
  How	
  To	
  Record	
  and	
  Play
                         Mommy,	
  I	
  found	
  it!	
  -­‐-­‐	
  15	
  PracNcal	
  Linux	
  Find	
  Command	
  Examples
                         15	
  Awesome	
  Gmail	
  Tips	
  and	
  Tricks
                         15	
  Awesome	
  Google	
  Search	
  Tips	
  and	
  Tricks
                         RAID	
  0,	
  RAID	
  1,	
  RAID	
  5,	
  RAID	
  10	
  Explained	
  with	
  Diagrams
                         Can	
  You	
  Top	
  This?	
  15	
  PracNcal	
  Linux	
  Top	
  Command	
  Examples
                         Top	
  5	
  Best	
  System	
  Monitoring	
  Tools
                         Top	
  5	
  Best	
  Linux	
  OS	
  DistribuNons
                         How	
  To	
  Monitor	
  Remote	
  Linux	
  Host	
  using	
  Nagios	
  3.0
                         Awk	
  IntroducNon	
  Tutorial	
  –	
  7	
  Awk	
  Print	
  Examples
                         How	
  to	
  Backup	
  Linux?	
  15	
  rsync	
  Command	
  Examples
                         The	
  UlNmate	
  Wget	
  Download	
  Guide	
  With	
  15	
  Awesome	
  Examples
                         Top	
  5	
  Best	
  Linux	
  Text	
  Editors
                         Packet	
  Analyzer:	
  15	
  TCPDUMP	
  Command	
  Examples
                         The	
  UlNmate	
  Bash	
  Array	
  Tutorial	
  with	
  15	
  Examples




6	
  of	
  7                                                                                                                                                            18	
  Apr	
  12	
  7:18	
  pm
15	
  PracNcal	
  PostgreSQL	
  Database	
  AdministraNon	
  Commands                                                                               hTp://www.thegeekstuff.com/2009/04/15-­‐pracNcal-­‐postgresql...


                                      3	
  Steps	
  to	
  Perform	
  SSH	
  Login	
  Without	
  Password	
  Using	
  ssh-­‐keygen	
  &	
  ssh-­‐copy-­‐id
                                      Unix	
  Sed	
  Tutorial:	
  Advanced	
  Sed	
  SubsNtuNon	
  Examples
                                      UNIX	
  /	
  Linux:	
  10	
  Netstat	
  Command	
  Examples
                                      The	
  UlNmate	
  Guide	
  for	
  CreaNng	
  Strong	
  Passwords
                                      6	
  Steps	
  to	
  Secure	
  Your	
  Home	
  Wireless	
  Network
                                      Turbocharge	
  PuTTY	
  with	
  12	
  Powerful	
  Add-­‐Ons

                          About	
  The	
  Geek	
  Stuff




                                               	
  My	
  name	
  is	
  Ramesh	
  Natarajan.	
  I	
  will	
  be	
  posNng	
  instrucNon	
  guides,	
  how-­‐to,	
  troubleshooNng	
  Nps	
  and	
  tricks	
  on	
  Linux,	
  database,
                          hardware,	
  security	
  and	
  web.	
  My	
  focus	
  is	
  to	
  write	
  arNcles	
  that	
  will	
  either	
  teach	
  you	
  or	
  help	
  you	
  resolve	
  a	
  problem.	
  Read	
  more	
  about	
  Ramesh	
  Natarajan
                          and	
  the	
  blog.

                          Support	
  Us


                          Support	
  this	
  blog	
  by	
  purchasing	
  one	
  of	
  my	
  ebooks.

                          Bash	
  101	
  Hacks	
  eBook

                          Sed	
  and	
  Awk	
  101	
  Hacks	
  eBook

                          Vim	
  101	
  Hacks	
  eBook

                          Nagios	
  Core	
  3	
  eBook

                          Contact	
  Us


                          Email	
  Me	
  :	
  Use	
  this	
  Contact	
  Form	
  to	
  get	
  in	
  touch	
  me	
  with	
  your	
  comments,	
  quesNons	
  or	
  suggesNons	
  about	
  this	
  site.	
  You	
  can	
  also	
  simply	
  drop	
  me	
  a	
  line
                          to	
  say	
  hello!.

                          Follow	
  us	
  on	
  TwiTer

                          Become	
  a	
  fan	
  on	
  Facebook	
  	
  

               Copyright	
  ©	
  2008–2012	
  Ramesh	
  Natarajan.	
  All	
  rights	
  reserved	
  |	
  Terms	
  of	
  Service	
  |	
  AdverNse




7	
  of	
  7                                                                                                                                                                                                                                     18	
  Apr	
  12	
  7:18	
  pm

Contenu connexe

Dernier

(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...AliaaTarek5
 
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Scott Andery
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityIES VE
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesThousandEyes
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...Wes McKinney
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPathCommunity
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch TuesdayIvanti
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Strongerpanagenda
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentPim van der Noll
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Farhan Tariq
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfIngrid Airi González
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
Manual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditManual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditSkynet Technologies
 

Dernier (20)

(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
 
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a reality
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to Hero
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch Tuesday
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdf
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
Manual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditManual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance Audit
 

En vedette

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by HubspotMarius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 

En vedette (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

15 practical postgre sql database administration commands

  • 1. 15  PracNcal  PostgreSQL  Database  AdministraNon  Commands hTp://www.thegeekstuff.com/2009/04/15-­‐pracNcal-­‐postgresql... Home About Free  eBook Archives Best  of  the  Blog Contact 15  Prac(cal  PostgreSQL  Database  Administra(on  Commands by  Ramesh  Natarajan  on  April  16,  2009 15 Like 7 Tweet 16 Earlier  we  discussed  about  how  to  install  PostgreSQL  database  on  Linux  from  source. In  this  arNcle,  let  us  review  top  15  pracNcal  postgreSQL  DBA  command  examples. If  you  are  a  mySQL  administrator,  check-­‐out  our  15  examples  of  mysqladmin  command  arNcle  that we  discussed  a  while  back. 1.  How  to  change  PostgreSQL  root  user  password  ? $ /usr/local/pgsql/bin/psql postgres postgres Password: (oldpassword) # ALTER USER postgres WITH PASSWORD 'tmppassword'; $ /usr/local/pgsql/bin/psql postgres postgres Password: (tmppassword) Changing  the  password  for  a  normal  postgres  user  is  similar  as  changing  the  password  of  the  root  user.  Root  user  can  change  the  password  of  any  user,  and  the normal  users  can  only  change  their  passwords  as  Unix  way  of  doing. # ALTER USER username WITH PASSWORD 'tmppassword'; 2.  How  to  setup  PostgreSQL  SysV  startup  script? $ su - root # tar xvfz postgresql-8.3.7.tar.gz # cd postgresql-8.3.7 # cp contrib/start-scripts/linux /etc/rc.d/init.d/postgresql # chmod a+x /etc/rc.d/init.d/postgresql 3.  How  to  check  whether  PostgreSQL  server  is  up  and  running? $ /etc/init.d/postgresql status Password: pg_ctl: server is running (PID: 6171) /usr/local/pgsql/bin/postgres "-D" "/usr/local/pgsql/data" [Note: The status above indicates the server is up and running] 1  of  7 18  Apr  12  7:18  pm
  • 2. 15  PracNcal  PostgreSQL  Database  AdministraNon  Commands hTp://www.thegeekstuff.com/2009/04/15-­‐pracNcal-­‐postgresql... $ /etc/init.d/postgresql status Password: pg_ctl: no server running [Note: The status above indicates the server is down] 4.  How  to  start,  stop  and  restart  PostgreSQL  database? # service postgresql stop Stopping PostgreSQL: server stopped ok # service postgresql start Starting PostgreSQL: ok # service postgresql restart Restarting PostgreSQL: server stopped ok 5.  How  do  I  find  out  what  version  of  PostgreSQL  I  am  running? $ /usr/local/pgsql/bin/psql test Welcome to psql 8.3.7, the PostgreSQL interactive terminal. Type: copyright for distribution terms h for help with SQL commands ? for help with psql commands g or terminate with semicolon to execute query q to quit test=# select version(); version ---------------------------------------------------------------------------------------------------- PostgreSQL 8.3.7 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 4.1.2 20071124 (Red Hat 4.1.2-42) (1 row) test=# 5.  How  to  create  a  PostgreSQL  user  ? There  are  two  methods  in  which  you  can  create  user. Method  1:  CreaNng  the  user  in  the  PSQL  prompt,  with  CREATE  USER  command. # CREATE USER ramesh WITH password 'tmppassword'; CREATE ROLE Method  2:  CreaNng  the  user  in  the  shell  prompt,  with  createuser  command. $ /usr/local/pgsql/bin/createuser sathiya Shall the new role be a superuser? (y/n) n Shall the new role be allowed to create databases? (y/n) n Shall the new role be allowed to create more new roles? (y/n) n CREATE ROLE 6.  How  to  create  a  PostgreSQL  Database  ? There  are  two  metods  in  which  you  can  create  two  databases. Method  1:  CreaNng  the  database  in  the  PSQL  prompt,  with  createuser  command. # CREATE DATABASE mydb WITH OWNER ramesh; CREATE DATABASE Method  2:  CreaNng  the  database  in  the  shell  prompt,  with  createdb  command. $ /usr/local/pgsql/bin/createdb mydb -O ramesh CREATE DATABASE *  -­‐O  owner  name  is  the  opNon  in  the  command  line. 2  of  7 18  Apr  12  7:18  pm
  • 3. 15  PracNcal  PostgreSQL  Database  AdministraNon  Commands hTp://www.thegeekstuff.com/2009/04/15-­‐pracNcal-­‐postgresql... 7.  How  do  I  get  a  list  of  databases  in  a  Postgresql  database  ? # l [Note: This is backslash followed by lower-case L] List of databases Name | Owner | Encoding ----------+----------+---------- backup | postgres | UTF8 mydb | ramesh | UTF8 postgres | postgres | UTF8 template0 | postgres | UTF8 template1 | postgres | UTF8 8.  How  to  Delete/Drop  an  exis(ng  PostgreSQL  database  ? # l List of databases Name | Owner | Encoding ----------+----------+---------- backup | postgres | UTF8 mydb | ramesh | UTF8 postgres | postgres | UTF8 template0 | postgres | UTF8 template1 | postgres | UTF8 # DROP DATABASE mydb; DROP DATABASE 9.  GeWng  help  on  postgreSQL  commands ?  will  show  PSQL  command  prompt  help.  h  CREATE  will  shows  help  about  all  the  commands  that  starts  with  CREATE,  when  you  want  something  specific  such as  help  for  creaNng  index,  then  you  need  to  give  CREATE  INDEX. # ? # h CREATE # h CREATE INDEX 10.  How  do  I  get  a  list  of  all  the  tables  in  a  Postgresql  database? # d On  an  empty  database,  you’ll  get  “No  relaNons  found.”  message  for  the  above  command. 11.  How  to  turn  on  (ming,  and  checking  how  much  (me  a  query  takes  to  execute  ? #  Nming  —  Ager  this  if  you  execute  a  query  it  will  show  how  much  Nme  it  took  for  doing  it. # timing Timing is on. # SELECT * from pg_catalog.pg_attribute ; Time: 9.583 ms 12.  How  To  Backup  and  Restore  PostgreSQL  Database  and  Table? We  discussed  earlier  how  to  backup  and  restore  postgres  database  and  tables  using  pg_dump  and  psql  uNlity. 13.  How  to  see  the  list  of  available  func(ons  in  PostgreSQL  ? To  get  to  know  more  about  the  funcNons,  say  df+ # df # df+ 14.  How  to  edit  PostgreSQL  queries  in  your  favorite  editor  ? # e 3  of  7 18  Apr  12  7:18  pm
  • 4. 15  PracNcal  PostgreSQL  Database  AdministraNon  Commands hTp://www.thegeekstuff.com/2009/04/15-­‐pracNcal-­‐postgresql... e  will  open  the  editor,  where  you  can  edit  the  queries  and  save  it.  By  doing  so  the  query  will  get  executed. 15.  Where  can  i  find  the  postgreSQL  history  file  ? Similar  to  the  Linux  ~/.bash_history  file,  postgreSQL  stores  all  the  sql  command  that  was  executed  in  a  history  filed  called  ~/.psql_history  as  shown  below. $ cat ~/.psql_history alter user postgres with password 'tmppassword'; h alter user select version(); create user ramesh with password 'tmppassword'; timing select * from pg_catalog.pg_attribute; 15 Tweet 16 Like 7  Share  Comment If  you  enjoyed  this  ar(cle,  you  might  also  like.. 1. 50  Linux  Sysadmin  Tutorials Awk  IntroducNon  –  7  Awk  Print  Examples 2. 50  Most  Frequently  Used  Linux  Commands  (With  Examples) Advanced  Sed  SubsNtuNon  Examples 3. Top  25  Best  Linux  Performance  Monitoring  and  Debugging  Tools 8  EssenNal  Vim  Editor  NavigaNon  Fundamentals 4. Mommy,  I  found  it!  –  15  PracNcal  Linux  Find  Command  Examples 25  Most  Frequently  Used  Linux  IPTables  Rules  Examples 5. Linux  101  Hacks  2nd  EdiNon  eBook   Turbocharge  PuTTY  with  12  Powerful  Add-­‐Ons Tags:  Change  Postgres  Password,  IdenNfy  PostgreSQL  Version,  Postgres,  PostgreSQL  database,  PostgreSQL  DB,  PostgreSQL  DBA  Commands,  PostgreSQL  psql command,  Start  and  Stop  PostgreSQL  Database,  ~/.psql_history {  6  comments…  read  them  below  or  add  one  } 1  sasikala  April  16,  2009  at  10:20  pm It  is  very  simple  but  more  useful.  thanks. 2  mike  March  21,  2010  at  10:41  pm very  useful  for  beginners  like  me.  Thanks. 3  karel  April  28,  2010  at  2:59  am ager  using d i  get  list  of  the  tables  ,and  highlighted (END) i  cannot  enter  any  text  or  command.  How  to  exit  the  descripNon  and  input  next  commands? 4  markitus82  May  18,  2010  at  10:03  am thanks!  nice  guide! 4  of  7 18  Apr  12  7:18  pm
  • 5. 15  PracNcal  PostgreSQL  Database  AdministraNon  Commands hTp://www.thegeekstuff.com/2009/04/15-­‐pracNcal-­‐postgresql... 5  NR  August  11,  2010  at  8:54  pm Some  clarificaNons: d  gaves  you  more  then  just  tables,  to  see  only  tables  use  dt.  To  see  views  use  dv,  to  see  a  table  or  any  other  object’s  descripNon  use  d  objectname. You  can  use  ?  to  see  a  list  of  commands  and  ?  commandname  to  get  help  with  a  command.  The  same  way  you  can  use  h  to  see  a  list  of  SQL commands  and  h  sqlcommand  to  get  help  with  a  SQL  command. Be  aware  that  a  simple  create  database  command  will  create  a  database  with  default  parameters,  this  is  not  always  what  we  want  or  need.  Usually  it  is ok  for  english  speakers  but  other  languages  migth  need  a  different  collaNng  order  or  even  encoding,  as  the  default  postgresql  installaNon  does  not  (or did  not)  use  UTF-­‐8.  To  change  this  and  other  parameters  in  a  safe  and  permanent  way  you  migth  need  to  create  a  all  new  database  cluster  as  some parameters  cannot  be  changed  ager  database  creaNon  and  others  have  to  be  common  to  all  databases  (see  hTp://www.postgresql.org/docs/8.4 /interacNve/locale.html  for  postgreSQL  8.4). Has  for  the  Karel’s  problem,  simply  use  ‘q’  to  quit  the  viewing  and  came  back  to  the  prompt. 6  Anonymous  September  20,  2011  at  11:50  pm this  is  very  useful  for  me Leave  a  Comment Name E-­‐mail Website  NoNfy  me  of  followup  comments  via  e-­‐mail Submit Previous  post:  Open  &  View  10  Different  File  Types  with  Linux  Less  Command  –  The  UlNmate  Power  of  Less Next  post:  Ctags  and  Taglist:  Convert  Vim  Editor  to  BeauNful  Source  Code  Browser  for  Any  Programming  Language Sign  up  for  our  free  email  newsleTer   you@address.com           Sign Up            RSS    TwiTer    Facebook   Search EBOOKS 5  of  7 18  Apr  12  7:18  pm
  • 6. 15  PracNcal  PostgreSQL  Database  AdministraNon  Commands hTp://www.thegeekstuff.com/2009/04/15-­‐pracNcal-­‐postgresql... POPULAR  POSTS 12  Amazing  and  EssenNal  Linux  Books  To  Enrich  Your  Brain  and  Library 50  UNIX  /  Linux  Sysadmin  Tutorials 50  Most  Frequently  Used  UNIX  /  Linux  Commands  (With  Examples) How  To  Be  ProducNve  and  Get  Things  Done  Using  GTD 30  Things  To  Do  When  you  are  Bored  and  have  a  Computer Linux  Directory  Structure  (File  System  Structure)  Explained  with  Examples Linux  Crontab:  15  Awesome  Cron  Job  Examples Get  a  Grip  on  the  Grep!  –  15  PracNcal  Grep  Command  Examples Unix  LS  Command:  15  PracNcal  Examples 15  Examples  To  Master  Linux  Command  Line  History Top  10  Open  Source  Bug  Tracking  System Vi  and  Vim  Macro  Tutorial:  How  To  Record  and  Play Mommy,  I  found  it!  -­‐-­‐  15  PracNcal  Linux  Find  Command  Examples 15  Awesome  Gmail  Tips  and  Tricks 15  Awesome  Google  Search  Tips  and  Tricks RAID  0,  RAID  1,  RAID  5,  RAID  10  Explained  with  Diagrams Can  You  Top  This?  15  PracNcal  Linux  Top  Command  Examples Top  5  Best  System  Monitoring  Tools Top  5  Best  Linux  OS  DistribuNons How  To  Monitor  Remote  Linux  Host  using  Nagios  3.0 Awk  IntroducNon  Tutorial  –  7  Awk  Print  Examples How  to  Backup  Linux?  15  rsync  Command  Examples The  UlNmate  Wget  Download  Guide  With  15  Awesome  Examples Top  5  Best  Linux  Text  Editors Packet  Analyzer:  15  TCPDUMP  Command  Examples The  UlNmate  Bash  Array  Tutorial  with  15  Examples 6  of  7 18  Apr  12  7:18  pm
  • 7. 15  PracNcal  PostgreSQL  Database  AdministraNon  Commands hTp://www.thegeekstuff.com/2009/04/15-­‐pracNcal-­‐postgresql... 3  Steps  to  Perform  SSH  Login  Without  Password  Using  ssh-­‐keygen  &  ssh-­‐copy-­‐id Unix  Sed  Tutorial:  Advanced  Sed  SubsNtuNon  Examples UNIX  /  Linux:  10  Netstat  Command  Examples The  UlNmate  Guide  for  CreaNng  Strong  Passwords 6  Steps  to  Secure  Your  Home  Wireless  Network Turbocharge  PuTTY  with  12  Powerful  Add-­‐Ons About  The  Geek  Stuff  My  name  is  Ramesh  Natarajan.  I  will  be  posNng  instrucNon  guides,  how-­‐to,  troubleshooNng  Nps  and  tricks  on  Linux,  database, hardware,  security  and  web.  My  focus  is  to  write  arNcles  that  will  either  teach  you  or  help  you  resolve  a  problem.  Read  more  about  Ramesh  Natarajan and  the  blog. Support  Us Support  this  blog  by  purchasing  one  of  my  ebooks. Bash  101  Hacks  eBook Sed  and  Awk  101  Hacks  eBook Vim  101  Hacks  eBook Nagios  Core  3  eBook Contact  Us Email  Me  :  Use  this  Contact  Form  to  get  in  touch  me  with  your  comments,  quesNons  or  suggesNons  about  this  site.  You  can  also  simply  drop  me  a  line to  say  hello!. Follow  us  on  TwiTer Become  a  fan  on  Facebook     Copyright  ©  2008–2012  Ramesh  Natarajan.  All  rights  reserved  |  Terms  of  Service  |  AdverNse 7  of  7 18  Apr  12  7:18  pm