~ubuntu-branches/ubuntu/trusty/postgresql-9.3/trusty-updates

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML
><HEAD
><TITLE
>CREATE ROLE</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
REV="MADE"
HREF="mailto:pgsql-docs@postgresql.org"><LINK
REL="HOME"
TITLE="PostgreSQL 9.3.13 Documentation"
HREF="index.html"><LINK
REL="UP"
TITLE="SQL Commands"
HREF="sql-commands.html"><LINK
REL="PREVIOUS"
TITLE="CREATE OPERATOR FAMILY"
HREF="sql-createopfamily.html"><LINK
REL="NEXT"
TITLE="CREATE RULE"
HREF="sql-createrule.html"><LINK
REL="STYLESHEET"
TYPE="text/css"
HREF="stylesheet.css"><META
HTTP-EQUIV="Content-Type"
CONTENT="text/html; charset=ISO-8859-1"><META
NAME="creation"
CONTENT="2016-05-09T21:13:26"></HEAD
><BODY
CLASS="REFENTRY"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="5"
ALIGN="center"
VALIGN="bottom"
><A
HREF="index.html"
>PostgreSQL 9.3.13 Documentation</A
></TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="top"
><A
TITLE="CREATE OPERATOR FAMILY"
HREF="sql-createopfamily.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="top"
><A
HREF="sql-commands.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="60%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="20%"
ALIGN="right"
VALIGN="top"
><A
TITLE="CREATE RULE"
HREF="sql-createrule.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><H1
><A
NAME="SQL-CREATEROLE"
></A
>CREATE ROLE</H1
><DIV
CLASS="REFNAMEDIV"
><A
NAME="AEN72021"
></A
><H2
>Name</H2
>CREATE ROLE&nbsp;--&nbsp;define a new database role</DIV
><DIV
CLASS="REFSYNOPSISDIV"
><A
NAME="AEN72026"
></A
><H2
>Synopsis</H2
><PRE
CLASS="SYNOPSIS"
>CREATE ROLE <TT
CLASS="REPLACEABLE"
><I
>name</I
></TT
> [ [ WITH ] <TT
CLASS="REPLACEABLE"
><I
>option</I
></TT
> [ ... ] ]

<SPAN
CLASS="phrase"
><SPAN
CLASS="PHRASE"
>where <TT
CLASS="REPLACEABLE"
><I
>option</I
></TT
> can be:</SPAN
></SPAN
>

      SUPERUSER | NOSUPERUSER
    | CREATEDB | NOCREATEDB
    | CREATEROLE | NOCREATEROLE
    | CREATEUSER | NOCREATEUSER
    | INHERIT | NOINHERIT
    | LOGIN | NOLOGIN
    | REPLICATION | NOREPLICATION
    | CONNECTION LIMIT <TT
CLASS="REPLACEABLE"
><I
>connlimit</I
></TT
>
    | [ ENCRYPTED | UNENCRYPTED ] PASSWORD '<TT
CLASS="REPLACEABLE"
><I
>password</I
></TT
>'
    | VALID UNTIL '<TT
CLASS="REPLACEABLE"
><I
>timestamp</I
></TT
>'
    | IN ROLE <TT
CLASS="REPLACEABLE"
><I
>role_name</I
></TT
> [, ...]
    | IN GROUP <TT
CLASS="REPLACEABLE"
><I
>role_name</I
></TT
> [, ...]
    | ROLE <TT
CLASS="REPLACEABLE"
><I
>role_name</I
></TT
> [, ...]
    | ADMIN <TT
CLASS="REPLACEABLE"
><I
>role_name</I
></TT
> [, ...]
    | USER <TT
CLASS="REPLACEABLE"
><I
>role_name</I
></TT
> [, ...]
    | SYSID <TT
CLASS="REPLACEABLE"
><I
>uid</I
></TT
></PRE
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN72041"
></A
><H2
>Description</H2
><P
>   <TT
CLASS="COMMAND"
>CREATE ROLE</TT
> adds a new role to a
   <SPAN
CLASS="PRODUCTNAME"
>PostgreSQL</SPAN
> database cluster.  A role is
   an entity that can own database objects and have database privileges;
   a role can be considered a <SPAN
CLASS="QUOTE"
>"user"</SPAN
>, a <SPAN
CLASS="QUOTE"
>"group"</SPAN
>, or both
   depending on how it is used.  Refer to
   <A
HREF="user-manag.html"
>Chapter 20</A
> and <A
HREF="client-authentication.html"
>Chapter 19</A
> for information about managing
   users and authentication.  You must have <TT
CLASS="LITERAL"
>CREATEROLE</TT
>
   privilege or be a database superuser to use this command.
  </P
><P
>   Note that roles are defined at the database cluster
   level, and so are valid in all databases in the cluster.
  </P
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN72052"
></A
><H2
>Parameters</H2
><P
></P
><DIV
CLASS="VARIABLELIST"
><DL
><DT
><TT
CLASS="REPLACEABLE"
><I
>name</I
></TT
></DT
><DD
><P
>        The name of the new role.
       </P
></DD
><DT
><TT
CLASS="LITERAL"
>SUPERUSER</TT
><BR><TT
CLASS="LITERAL"
>NOSUPERUSER</TT
></DT
><DD
><P
>        These clauses determine whether the new role is a <SPAN
CLASS="QUOTE"
>"superuser"</SPAN
>,
        who can override all access restrictions within the database.
        Superuser status is dangerous and should be used only when really
        needed.  You must yourself be a superuser to create a new superuser.
        If not specified,
        <TT
CLASS="LITERAL"
>NOSUPERUSER</TT
> is the default.
       </P
></DD
><DT
><TT
CLASS="LITERAL"
>CREATEDB</TT
><BR><TT
CLASS="LITERAL"
>NOCREATEDB</TT
></DT
><DD
><P
>        These clauses define a role's ability to create databases.  If
        <TT
CLASS="LITERAL"
>CREATEDB</TT
> is specified, the role being
        defined will be allowed to create new databases. Specifying
        <TT
CLASS="LITERAL"
>NOCREATEDB</TT
> will deny a role the ability to
        create databases. If not specified,
        <TT
CLASS="LITERAL"
>NOCREATEDB</TT
> is the default.
       </P
></DD
><DT
><TT
CLASS="LITERAL"
>CREATEROLE</TT
><BR><TT
CLASS="LITERAL"
>NOCREATEROLE</TT
></DT
><DD
><P
>        These clauses determine whether a role will be permitted to
        create new roles (that is, execute <TT
CLASS="COMMAND"
>CREATE ROLE</TT
>).
        A role with <TT
CLASS="LITERAL"
>CREATEROLE</TT
> privilege can also alter
        and drop other roles.
        If not specified,
        <TT
CLASS="LITERAL"
>NOCREATEROLE</TT
> is the default.
       </P
></DD
><DT
><TT
CLASS="LITERAL"
>CREATEUSER</TT
><BR><TT
CLASS="LITERAL"
>NOCREATEUSER</TT
></DT
><DD
><P
>        These clauses are an obsolete, but still accepted, spelling of
        <TT
CLASS="LITERAL"
>SUPERUSER</TT
> and <TT
CLASS="LITERAL"
>NOSUPERUSER</TT
>.
        Note that they are <SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>not</I
></SPAN
> equivalent to
        <TT
CLASS="LITERAL"
>CREATEROLE</TT
> as one might naively expect!
       </P
></DD
><DT
><TT
CLASS="LITERAL"
>INHERIT</TT
><BR><TT
CLASS="LITERAL"
>NOINHERIT</TT
></DT
><DD
><P
>        These clauses determine whether a role <SPAN
CLASS="QUOTE"
>"inherits"</SPAN
> the
        privileges of roles it is a member of.
        A role with the <TT
CLASS="LITERAL"
>INHERIT</TT
> attribute can automatically
        use whatever database privileges have been granted to all roles
        it is directly or indirectly a member of.
        Without <TT
CLASS="LITERAL"
>INHERIT</TT
>, membership in another role
        only grants the ability to <TT
CLASS="COMMAND"
>SET ROLE</TT
> to that other role;
        the privileges of the other role are only available after having
        done so.
        If not specified,
        <TT
CLASS="LITERAL"
>INHERIT</TT
> is the default.
       </P
></DD
><DT
><TT
CLASS="LITERAL"
>LOGIN</TT
><BR><TT
CLASS="LITERAL"
>NOLOGIN</TT
></DT
><DD
><P
>        These clauses determine whether a role is allowed to log in;
        that is, whether the role can be given as the initial session
        authorization name during client connection.  A role having
        the <TT
CLASS="LITERAL"
>LOGIN</TT
> attribute can be thought of as a user.
        Roles without this attribute are useful for managing database
        privileges, but are not users in the usual sense of the word.
        If not specified,
        <TT
CLASS="LITERAL"
>NOLOGIN</TT
> is the default, except when
        <TT
CLASS="COMMAND"
>CREATE ROLE</TT
> is invoked through its alternative spelling
        <A
HREF="sql-createuser.html"
>CREATE USER</A
>.
       </P
></DD
><DT
><TT
CLASS="LITERAL"
>REPLICATION</TT
><BR><TT
CLASS="LITERAL"
>NOREPLICATION</TT
></DT
><DD
><P
>        These clauses determine whether a role is allowed to initiate
        streaming replication or put the system in and out of backup mode.
        A role having the <TT
CLASS="LITERAL"
>REPLICATION</TT
> attribute is a very
        highly privileged role, and should only be used on roles actually
        used for replication. If not specified,
        <TT
CLASS="LITERAL"
>NOREPLICATION</TT
> is the default.
       </P
></DD
><DT
><TT
CLASS="LITERAL"
>CONNECTION LIMIT</TT
> <TT
CLASS="REPLACEABLE"
><I
>connlimit</I
></TT
></DT
><DD
><P
>        If role can log in, this specifies how many concurrent connections
        the role can make.  -1 (the default) means no limit.
       </P
></DD
><DT
><TT
CLASS="LITERAL"
>PASSWORD</TT
> <TT
CLASS="REPLACEABLE"
><I
>password</I
></TT
></DT
><DD
><P
>        Sets the role's password.  (A password is only of use for
        roles having the <TT
CLASS="LITERAL"
>LOGIN</TT
> attribute, but you
        can nonetheless define one for roles without it.)  If you do
        not plan to use password authentication you can omit this
        option.  If no password is specified, the password will be set
        to null and password authentication will always fail for that
        user.  A null password can optionally be written explicitly as
        <TT
CLASS="LITERAL"
>PASSWORD NULL</TT
>.
       </P
></DD
><DT
><TT
CLASS="LITERAL"
>ENCRYPTED</TT
><BR><TT
CLASS="LITERAL"
>UNENCRYPTED</TT
></DT
><DD
><P
>        These key words control whether the password is stored
        encrypted in the system catalogs.  (If neither is specified,
        the default behavior is determined by the configuration
        parameter <A
HREF="runtime-config-connection.html#GUC-PASSWORD-ENCRYPTION"
>password_encryption</A
>.)  If the
        presented password string is already in MD5-encrypted format,
        then it is stored encrypted as-is, regardless of whether
        <TT
CLASS="LITERAL"
>ENCRYPTED</TT
> or <TT
CLASS="LITERAL"
>UNENCRYPTED</TT
> is specified
        (since the system cannot decrypt the specified encrypted
        password string).  This allows reloading of encrypted
        passwords during dump/restore.
       </P
><P
>        Note that older clients might lack support for the MD5
        authentication mechanism that is needed to work with passwords
        that are stored encrypted.
       </P
></DD
><DT
><TT
CLASS="LITERAL"
>VALID UNTIL</TT
> '<TT
CLASS="REPLACEABLE"
><I
>timestamp</I
></TT
>'</DT
><DD
><P
>        The <TT
CLASS="LITERAL"
>VALID UNTIL</TT
> clause sets a date and
        time after which the role's password is no longer valid.  If
        this clause is omitted the password will be valid for all time.
       </P
></DD
><DT
><TT
CLASS="LITERAL"
>IN ROLE</TT
> <TT
CLASS="REPLACEABLE"
><I
>role_name</I
></TT
></DT
><DD
><P
>        The <TT
CLASS="LITERAL"
>IN ROLE</TT
> clause lists one or more existing
        roles to which the new role will be immediately added as a new
        member.  (Note that there is no option to add the new role as an
        administrator; use a separate <TT
CLASS="COMMAND"
>GRANT</TT
> command to do that.)
       </P
></DD
><DT
><TT
CLASS="LITERAL"
>IN GROUP</TT
> <TT
CLASS="REPLACEABLE"
><I
>role_name</I
></TT
></DT
><DD
><P
><TT
CLASS="LITERAL"
>IN GROUP</TT
> is an obsolete spelling of
        <TT
CLASS="LITERAL"
>IN ROLE</TT
>.
       </P
></DD
><DT
><TT
CLASS="LITERAL"
>ROLE</TT
> <TT
CLASS="REPLACEABLE"
><I
>role_name</I
></TT
></DT
><DD
><P
>        The <TT
CLASS="LITERAL"
>ROLE</TT
> clause lists one or more existing
        roles which are automatically added as members of the new role.
        (This in effect makes the new role a <SPAN
CLASS="QUOTE"
>"group"</SPAN
>.)
       </P
></DD
><DT
><TT
CLASS="LITERAL"
>ADMIN</TT
> <TT
CLASS="REPLACEABLE"
><I
>role_name</I
></TT
></DT
><DD
><P
>        The <TT
CLASS="LITERAL"
>ADMIN</TT
> clause is like <TT
CLASS="LITERAL"
>ROLE</TT
>,
        but the named roles are added to the new role <TT
CLASS="LITERAL"
>WITH ADMIN
        OPTION</TT
>, giving them the right to grant membership in this role
        to others.
       </P
></DD
><DT
><TT
CLASS="LITERAL"
>USER</TT
> <TT
CLASS="REPLACEABLE"
><I
>role_name</I
></TT
></DT
><DD
><P
>        The <TT
CLASS="LITERAL"
>USER</TT
> clause is an obsolete spelling of
        the <TT
CLASS="LITERAL"
>ROLE</TT
> clause.
       </P
></DD
><DT
><TT
CLASS="LITERAL"
>SYSID</TT
> <TT
CLASS="REPLACEABLE"
><I
>uid</I
></TT
></DT
><DD
><P
>        The <TT
CLASS="LITERAL"
>SYSID</TT
> clause is ignored, but is accepted
        for backwards compatibility.
       </P
></DD
></DL
></DIV
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN72212"
></A
><H2
>Notes</H2
><P
>   Use <A
HREF="sql-alterrole.html"
>ALTER ROLE</A
> to
   change the attributes of a role, and <A
HREF="sql-droprole.html"
>DROP ROLE</A
>
   to remove a role.  All the attributes
   specified by <TT
CLASS="COMMAND"
>CREATE ROLE</TT
> can be modified by later
   <TT
CLASS="COMMAND"
>ALTER ROLE</TT
> commands.
  </P
><P
>   The preferred way to add and remove members of roles that are being
   used as groups is to use
   <A
HREF="sql-grant.html"
>GRANT</A
> and
   <A
HREF="sql-revoke.html"
>REVOKE</A
>.
  </P
><P
>   The <TT
CLASS="LITERAL"
>VALID UNTIL</TT
> clause defines an expiration time for a
   password only, not for the role <I
CLASS="FOREIGNPHRASE"
>per se</I
>.  In
   particular, the expiration time is not enforced when logging in using
   a non-password-based authentication method.
  </P
><P
>   The <TT
CLASS="LITERAL"
>INHERIT</TT
> attribute governs inheritance of grantable
   privileges (that is, access privileges for database objects and role
   memberships).  It does not apply to the special role attributes set by
   <TT
CLASS="COMMAND"
>CREATE ROLE</TT
> and <TT
CLASS="COMMAND"
>ALTER ROLE</TT
>.  For example, being
   a member of a role with <TT
CLASS="LITERAL"
>CREATEDB</TT
> privilege does not immediately
   grant the ability to create databases, even if <TT
CLASS="LITERAL"
>INHERIT</TT
> is set;
   it would be necessary to become that role via
   <A
HREF="sql-set-role.html"
>SET ROLE</A
> before
   creating a database.
  </P
><P
>   The <TT
CLASS="LITERAL"
>INHERIT</TT
> attribute is the default for reasons of backwards
   compatibility: in prior releases of <SPAN
CLASS="PRODUCTNAME"
>PostgreSQL</SPAN
>,
   users always had access to all privileges of groups they were members of.
   However, <TT
CLASS="LITERAL"
>NOINHERIT</TT
> provides a closer match to the semantics
   specified in the SQL standard.
  </P
><P
>   Be careful with the <TT
CLASS="LITERAL"
>CREATEROLE</TT
> privilege. There is no concept of
   inheritance for the privileges of a <TT
CLASS="LITERAL"
>CREATEROLE</TT
>-role. That
   means that even if a role does not have a certain privilege but is allowed
   to create other roles, it can easily create another role with different
   privileges than its own (except for creating roles with superuser
   privileges). For example, if the role <SPAN
CLASS="QUOTE"
>"user"</SPAN
> has the
   <TT
CLASS="LITERAL"
>CREATEROLE</TT
> privilege but not the <TT
CLASS="LITERAL"
>CREATEDB</TT
> privilege,
   nonetheless it can create a new role with the <TT
CLASS="LITERAL"
>CREATEDB</TT
>
   privilege. Therefore, regard roles that have the <TT
CLASS="LITERAL"
>CREATEROLE</TT
>
   privilege as almost-superuser-roles.
  </P
><P
>   <SPAN
CLASS="PRODUCTNAME"
>PostgreSQL</SPAN
> includes a program <A
HREF="app-createuser.html"
><SPAN
CLASS="APPLICATION"
>createuser</SPAN
></A
> that has
   the same functionality as <TT
CLASS="COMMAND"
>CREATE ROLE</TT
> (in fact,
   it calls this command) but can be run from the command shell.
  </P
><P
>   The <TT
CLASS="LITERAL"
>CONNECTION LIMIT</TT
> option is only enforced approximately;
   if two new sessions start at about the same time when just one
   connection <SPAN
CLASS="QUOTE"
>"slot"</SPAN
> remains for the role, it is possible that
   both will fail.  Also, the limit is never enforced for superusers.
  </P
><P
>   Caution must be exercised when specifying an unencrypted password
   with this command.  The password will be transmitted to the server
   in cleartext, and it might also be logged in the client's command
   history or the server log.  The command <A
HREF="app-createuser.html"
><SPAN
CLASS="APPLICATION"
>createuser</SPAN
></A
>, however, transmits
   the password encrypted.  Also, <A
HREF="app-psql.html"
><SPAN
CLASS="APPLICATION"
>psql</SPAN
></A
>
   contains a command
   <TT
CLASS="COMMAND"
>\password</TT
> that can be used to safely change the
   password later.
  </P
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN72255"
></A
><H2
>Examples</H2
><P
>   Create a role that can log in, but don't give it a password:
</P><PRE
CLASS="PROGRAMLISTING"
>CREATE ROLE jonathan LOGIN;</PRE
><P>
  </P
><P
>   Create a role with a password:
</P><PRE
CLASS="PROGRAMLISTING"
>CREATE USER davide WITH PASSWORD 'jw8s0F4';</PRE
><P>
   (<TT
CLASS="COMMAND"
>CREATE USER</TT
> is the same as <TT
CLASS="COMMAND"
>CREATE ROLE</TT
> except
   that it implies <TT
CLASS="LITERAL"
>LOGIN</TT
>.)
  </P
><P
>   Create a role with a password that is valid until the end of 2004.
   After one second has ticked in 2005, the password is no longer
   valid.

</P><PRE
CLASS="PROGRAMLISTING"
>CREATE ROLE miriam WITH LOGIN PASSWORD 'jw8s0F4' VALID UNTIL '2005-01-01';</PRE
><P>
  </P
><P
>   Create a role that can create databases and manage roles:
</P><PRE
CLASS="PROGRAMLISTING"
>CREATE ROLE admin WITH CREATEDB CREATEROLE;</PRE
><P></P
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN72268"
></A
><H2
>Compatibility</H2
><P
>   The <TT
CLASS="COMMAND"
>CREATE ROLE</TT
> statement is in the SQL standard,
   but the standard only requires the syntax
</P><PRE
CLASS="SYNOPSIS"
>CREATE ROLE <TT
CLASS="REPLACEABLE"
><I
>name</I
></TT
> [ WITH ADMIN <TT
CLASS="REPLACEABLE"
><I
>role_name</I
></TT
> ]</PRE
><P>
   Multiple initial administrators, and all the other options of
   <TT
CLASS="COMMAND"
>CREATE ROLE</TT
>, are
   <SPAN
CLASS="PRODUCTNAME"
>PostgreSQL</SPAN
> extensions.
  </P
><P
>   The SQL standard defines the concepts of users and roles, but it
   regards them as distinct concepts and leaves all commands defining
   users to be specified by each database implementation.  In
   <SPAN
CLASS="PRODUCTNAME"
>PostgreSQL</SPAN
> we have chosen to unify
   users and roles into a single kind of entity.  Roles therefore
   have many more optional attributes than they do in the standard.
  </P
><P
>   The behavior specified by the SQL standard is most closely approximated
   by giving users the <TT
CLASS="LITERAL"
>NOINHERIT</TT
> attribute, while roles are
   given the <TT
CLASS="LITERAL"
>INHERIT</TT
> attribute.
  </P
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN72282"
></A
><H2
>See Also</H2
><A
HREF="sql-set-role.html"
>SET ROLE</A
>, <A
HREF="sql-alterrole.html"
>ALTER ROLE</A
>, <A
HREF="sql-droprole.html"
>DROP ROLE</A
>, <A
HREF="sql-grant.html"
>GRANT</A
>, <A
HREF="sql-revoke.html"
>REVOKE</A
>, <A
HREF="app-createuser.html"
><SPAN
CLASS="APPLICATION"
>createuser</SPAN
></A
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="sql-createopfamily.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="sql-createrule.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>CREATE OPERATOR FAMILY</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="sql-commands.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>CREATE RULE</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>