zoukankan      html  css  js  c++  java
  • postgres创建用户,表

    使用createuser来创建用户

    1. [postgres@web1 ~]$ /data/pgsql/bin/createuser --help  
    2. createuser creates a new PostgreSQL role.  
    3.   
    4. Usage:  
    5.   createuser [OPTION]... [ROLENAME]  
    6.   
    7. Options:  
    8.   -c, --connection-limit=N  connection limit for role (default: no limit)  
    9.   -d, --createdb            role can create new databases  
    10.   -D, --no-createdb         role cannot create databases (default)  
    11.   -e, --echo                show the commands being sent to the server  
    12.   -E, --encrypted           encrypt stored password  
    13.   -i, --inherit             role inherits privileges of roles it is a  
    14.                             member of (default)  
    15.   -I, --no-inherit          role does not inherit privileges  
    16.   -l, --login               role can login (default)  
    17.   -L, --no-login            role cannot login  
    18.   -N, --unencrypted         do not encrypt stored password  
    19.   -P, --pwprompt            assign a password to new role  
    20.   -r, --createrole          role can create new roles  
    21.   -R, --no-createrole       role cannot create roles (default)  
    22.   -s, --superuser           role will be superuser  
    23.   -S, --no-superuser        role will not be superuser (default)  
    24.   -V, --version             output version information, then exit  
    25.   --interactive             prompt for missing role name and attributes rather  
    26.                             than using defaults  
    27.   --replication             role can initiate replication  
    28.   --no-replication          role cannot initiate replication  
    29.   -?, --help                show this help, then exit  
    30.   
    31. Connection options:  
    32.   -h, --host=HOSTNAME       database server host or socket directory  
    33.   -p, --port=PORT           database server port  
    34.   -U, --username=USERNAME   user name to connect as (not the one to create)  
    35.   -w, --no-password         never prompt for password  
    36.   -W, --password            force password prompt  
    37.   
    38. Report bugs to <pgsql-bugs@postgresql.org>.  
    39. [postgres@web1 ~]$   
    40. [postgres@web1 ~]$   
    41. [postgres@web1 ~]$ /data/pgsql/bin/createuser zhongwc -P  
    42. Enter password for new role:   
    43. Enter it again:   
    44. [postgres@web1 ~]$   

    使用createdb创建数据库

    1. [postgres@web1 ~]$ /data/pgsql/bin/createdb --help  
    2. createdb creates a PostgreSQL database.  
    3.   
    4. Usage:  
    5.   createdb [OPTION]... [DBNAME] [DESCRIPTION]  
    6.   
    7. Options:  
    8.   -D, --tablespace=TABLESPACE  default tablespace for the database  
    9.   -e, --echo                   show the commands being sent to the server  
    10.   -E, --encoding=ENCODING      encoding for the database  
    11.   -l, --locale=LOCALE          locale settings for the database  
    12.       --lc-collate=LOCALE      LC_COLLATE setting for the database  
    13.       --lc-ctype=LOCALE        LC_CTYPE setting for the database  
    14.   -O, --owner=OWNER            database user to own the new database  
    15.   -T, --template=TEMPLATE      template database to copy  
    16.   -V, --version                output version information, then exit  
    17.   -?, --help                   show this help, then exit  
    18.   
    19. Connection options:  
    20.   -h, --host=HOSTNAME          database server host or socket directory  
    21.   -p, --port=PORT              database server port  
    22.   -U, --username=USERNAME      user name to connect as  
    23.   -w, --no-password            never prompt for password  
    24.   -W, --password               force password prompt  
    25.   --maintenance-db=DBNAME      alternate maintenance database  
    26.   
    27. By default, a database with the same name as the current user is created.  
    28.   
    29. Report bugs to <pgsql-bugs@postgresql.org>.  
    30. [postgres@web1 ~]$   
    31. [postgres@web1 ~]$   
    32. [postgres@web1 ~]$ /data/pgsql/bin/createdb zwcdb  
    1. [postgres@web1 ~]$ psql -U zhongwc -d zwcdb  
    2. psql (9.2.2)  
    3. Type "help" for help.  
    4.   
    5. zwcdb=> help  
    6. You are using psql, the command-line interface to PostgreSQL.  
    7. Type:  copyright for distribution terms  
    8.        h for help with SQL commands  
    9.        ? for help with psql commands  
    10.        g or terminate with semicolon to execute query  
    11.        q to quit  
    12. zwcdb=>   



    创建表

    1. [postgres@web1 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.   
    6. zwcdb=> create table t_zhongwc(pid integer,pname varchar(32),constraint zhongwc_pid_pk primary key(pid));  
    7. NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "zhongwc_pid_pk" for table "t_zhongwc"  
    8. CREATE TABLE  
    9. zwcdb=>   
    10. zwcdb=> select * from t_zhongwc;  
    11.  pid | pname   
    12. -----+-------  
    13. (0 rows)  


    删除表

      1. zwcdb=> drop table t_zhongwc;  
      2. DROP TABLE  
      3. zwcdb=> drop table t_zhongwc;  
      4. ERROR:  table "t_zhongwc" does not exist  
  • 相关阅读:
    php foreach的使用注意
    php数组遍历 使用foreach
    PHP strip_tags() 函数
    php nl2br() 函数
    php文件上传
    一个网站雏形
    jsp接收相同复合参数 request.getParameterValues()用法
    使用div+css制作简单导航 以及要注意问题
    Java 类与对象
    java 基础
  • 原文地址:https://www.cnblogs.com/liqing1009/p/5035260.html
Copyright © 2011-2022 走看看