pgadmin4/docs/en_US/sequence_dialog.rst

84 lines
5.0 KiB
ReStructuredText
Raw Normal View History

2016-05-20 20:39:21 +00:00
***************
Sequence Dialog
***************
2016-05-13 13:43:57 +00:00
2016-05-20 20:39:21 +00:00
Use the *Sequence* dialog to create a sequence. A sequence generates unique values in a sequential order (not necessarily contiguous).
2016-05-13 13:43:57 +00:00
2016-05-20 20:39:21 +00:00
The *Sequence* dialog allows you to implement options of the CREATE SEQUENCE command. For more information about the CREATE SEQUENCE command, see the PostgreSQL core documentation available at:
2016-05-13 13:43:57 +00:00
http://www.postgresql.org/docs/9.5/static/sql-createsequence.html
2016-05-20 20:39:21 +00:00
The *Sequence* dialog organizes the development of a sequence through the following dialog tabs: *General*, *Definition*, and *Security*. The *SQL* tab displays the SQL code generated by dialog selections.
2016-05-13 13:43:57 +00:00
2016-05-20 20:39:21 +00:00
.. image:: images/sequence_general.png
2016-05-13 13:43:57 +00:00
:align: center
Use the fields in the *General* tab to identify a sequence:
* Use the *Name* field to add a descriptive name for the sequence. The name will be displayed in the *pgAdmin* tree control. The sequence name must be distinct from the name of any other sequence, table, index, view, or foreign table in the same schema.
* Use the drop-down listbox next to *Owner* to select the name of the role that will own the extension.
* Use the drop-down listbox next to *Schema* to select an existing schema.
* Store notes about the sequence in the *Comments* field.
Click the *Definition* tab to continue.
2016-05-20 20:39:21 +00:00
.. image:: images/sequence_definition.png
2016-05-13 13:43:57 +00:00
:align: center
Use the fields in the *Definition* tab to define the sequence:
* Use the *Increment* field to specify which value is added to the current sequence value to create a new value.
* Provide a value in the *Start* field to specify the beginning value of the sequence. The default starting value is MINVALUE for ascending sequences and MAXVALUE for descending ones.
* Provide a value in the *Minimum* field to specify the minimum value a sequence can generate. If this clause is not supplied or NO MINVALUE is specified, then defaults will be used. The defaults are 1 and -263-1 for ascending and descending sequences, respectively.
* Provide a value in the *Maximum* field to specify the maximum value for the sequence. If this clause is not supplied or NO MAXVALUE is specified, then default values will be used. The defaults are 263-1 and -1 for ascending and descending sequences, respectively.
* Provide a value in the *Cache* field to specify how many sequence numbers are to be preallocated and stored in memory for faster access. The minimum value is 1 (only one value can be generated at a time, i.e., no cache), and this is also the default.
* Check the *Cycled* checkbox to allow the sequence to wrap around when the MAXVALUE or the MINVALUE has been reached by an ascending or descending sequence respectively. If the limit is reached, the next number generated will be the MINVALUE or MAXVALUE, respectively.
Click the *Security* tab to continue.
2016-05-20 20:39:21 +00:00
.. image:: images/sequence_security.png
2016-05-13 13:43:57 +00:00
:align: center
Use the *Security* tab to assign privileges and define security labels.
Use the *Privileges* panel to assign privileges to a role. Click *Add* to set privileges for database objects:
* Select the name of the role from the drop-down listbox in the *Grantee* field.
* Click inside the *Privileges* field. Check the boxes to the left of one or more privileges to grant the selected privilege to the specified user.
* Select the name of the role from the drop-down listbox in the *Grantor* field. The default grantor is the owner of the database.
Click *Add* to assign additional privileges; to discard a privilege, click the trash icon to the left of the row and confirm deletion in the *Delete Row* popup.
Use the *Security Labels* panel to define security labels applied to the function. Click *Add* to add each security label selection:
* Specify a security label provider in the *Provider* field. The named provider must be loaded and must consent to the proposed labeling operation.
* Specify a a security label in the *Security Label* field. The meaning of a given label is at the discretion of the label provider. PostgreSQL places no restrictions on whether or how a label provider must interpret security labels; it merely provides a mechanism for storing them.
Click *Add* to assign additional security labels; to discard a security label, click the trash icon to the left of the row and confirm deletion in the *Delete Row* popup.
Click the *SQL* tab to continue.
2016-05-20 20:39:21 +00:00
.. image:: images/sequence_sql.png
2016-05-13 13:43:57 +00:00
:align: center
2016-05-20 20:39:21 +00:00
Your entries in the *Sequence* dialog generate a generate a SQL command; you can review the command on the *SQL* pane.
2016-05-13 13:43:57 +00:00
* Click the *Info* button (i) to access online help.
* Click the *Save* button to save work.
* Click the *Cancel* button to exit without saving work.
* Click the *Reset* button to restore configuration parameters.
Example
=======
2016-05-20 20:39:21 +00:00
The following is an example of the sql command generated by user selections in the *Database dialog*:
2016-05-13 13:43:57 +00:00
2016-05-20 20:39:21 +00:00
.. image:: images/sequence_sql_example.png
2016-05-13 13:43:57 +00:00
The example shown demonstrates a sequence named *seconds*. It will increment by *5* with a start value equal to *0* (cached) and a maximum value equal to *60*.