Postgres Create user, table

Source: Internet
Author: User
Tags psql

Use CreateUser to create a user

[Plain]View Plaincopyprint?
  1. [Email protected] ~]$/data/pgsql/bin/createuser--help
  2. CreateUser creates a new PostgreSQL role.
  3. Usage:
  4. CreateUser [OPTION] ... [ROLENAME]
  5. Options:
  6. -C,--connection-limit=n connection limit for role (Default:no limit)
  7. -D,--createdb role can create new databases
  8. -D,--no-createdb role cannot create databases (default)
  9. -E,--echo show the commands being sent to the server
  10. -E,--encrypted encrypt stored password
  11. -I,--inherit role inherits privileges of roles it is a
  12. Member of (default)
  13. -I,--no-inherit role does not inherit privileges
  14. -L,--login role can login (default)
  15. -L,--no-login role cannot login
  16. -N,--unencrypted do not encrypt stored password
  17. -P,--pwprompt assign a password to new role
  18. -R,--createrole role can create new roles
  19. -R,--no-createrole role cannot create roles (default)
  20. -S,--superuser role would be superuser
  21. -S,--no-superuser role won't be superuser (default)
  22. -V,--version output version information, then exit
  23. --interactive prompt for missing role name and attributes rather
  24. than using defaults
  25. --replication role can initiate replication
  26. --no-replication role cannot initiate replication
  27. -?,--Help show this help and then exit
  28. Connection options:
  29. -H,--host=hostname database server host or socket directory
  30. -p,--port=port database server port
  31. -U,--username=username user name to connect as (not the one to create)
  32. -W,--no-password never prompt for password
  33. -W,--password force password prompt
  34. Report bugs to <[email Protected]>.
  35. [Email protected] ~]$
  36. [Email protected] ~]$
  37. [Email protected] ~]$/data/pgsql/bin/createuser zhongwc-p
  38. Enter Password for new role:
  39. Enter It again:
  40. [Email protected] ~]$

Create a database using Createdb

[Plain]View Plaincopyprint?
  1. [Email protected] ~]$/data/pgsql/bin/createdb--help
  2. Createdb creates a PostgreSQL database.
  3. Usage:
  4. Createdb [OPTION] ... [DBNAME] [DESCRIPTION]
  5. Options:
  6. -D,--tablespace=tablespace default tablespace for the database
  7. -E,--echo show the commands being sent to the server
  8. -E,--encoding=encoding encoding for the database
  9. -L,--locale=locale locale settings for the database
  10. --lc-collate=locale lc_collate setting for the database
  11. --lc-ctype=locale lc_ctype setting for the database
  12. -O,--owner=owner database user to own the new database
  13. -T,--template=template template database to copy
  14. -V,--version output version information, then exit
  15. -?,--Help show this help and then exit
  16. Connection options:
  17. -H,--host=hostname database server host or socket directory
  18. -p,--port=port database server port
  19. -U,--username=username user name to connect as
  20. -W,--no-password never prompt for password
  21. -W,--password force password prompt
  22. --maintenance-db=dbname Alternate Maintenance Database
  23. By default, a database with the same name as the current user is created.
  24. Report bugs to <[email Protected]>.
  25. [Email protected] ~]$
  26. [Email protected] ~]$
  27. [Email protected] ~]$/data/pgsql/bin/createdb zwcdb
[Plain]View Plaincopyprint?
  1. [Email protected] ~]$ psql-u zhongwc-d zwcdb
  2. Psql (9.2.2)
  3. Type ' help ' for help.
  4. Zwcdb=> Help
  5. You is using Psql, the command-line interface to PostgreSQL.
  6. Type: \copyright for distribution Terms
  7. \h for help with SQL commands
  8. \? For help with Psql commands
  9. \g or terminate with semicolon to execute query
  10. \q to quit
  11. Zwcdb=>



Create a table

[Plain]View Plaincopyprint?
  1. [Email protected] data]$ psql-u zhongwc-d zwcdb-h 192.168.1.203-p 1521
  2. Password for user zhongwc:
  3. Psql (9.2.2)
  4. Type ' help ' for help.
  5. Zwcdb=> CREATE TABLE T_ZHONGWC (PID integer,pname varchar (+), constraint ZHONGWC_PID_PK primary key (PID));
  6. Notice:create table/primary KEY would CREATE implicit index "ZHONGWC_PID_PK" for TABLE "T_ZHONGWC"
  7. CREATE TABLE
  8. Zwcdb=>
  9. Zwcdb=> select * from T_ZHONGWC;
  10. PID | PName
  11. -----+-------
  12. (0 rows)


Delete a table

[Plain]View Plaincopyprint?
      1. zwcdb=> drop table T_ZHONGWC;
      2. DROP TABLE
      3. zwcdb=> drop table T_ZHONGWC;
      4. Error:table "T_ZHONGWC" does not exist

Postgres Create user, table

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.