File tree Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -121,6 +121,7 @@ smart people at [Hashrocket](http://hashrocket.com/).
121
121
- [ List All Columns Of A Specific Type] ( postgres/list-all-columns-of-a-specific-type.md )
122
122
- [ List All Versions Of A Function] ( postgres/list-all-versions-of-a-function.md )
123
123
- [ List Database Users] ( postgres/list-database-users.md )
124
+ - [ Restart A Sequence] ( postgres/restart-a-sequence.md )
124
125
- [ Send A Command To psql] ( postgres/send-a-command-to-psql.md )
125
126
- [ Special Math Operators] ( postgres/special-math-operators.md )
126
127
- [ String Contains Another String] ( postgres/string-contains-another-string.md )
Original file line number Diff line number Diff line change
1
+ # Restart A Sequence
2
+
3
+ In postgres, if you are truncating a table or doing some other sort of
4
+ destructive action on a table in a development or testing environment, you
5
+ may notice that the id sequence for the primary key just keeps plugging
6
+ along from where it last left off. The sequence can be reset to any value
7
+ like so:
8
+
9
+ ``` sql
10
+ > alter sequence my_table_id_seq restart with 1 ;
11
+ ALTER SEQUENCE
12
+ ```
13
+
14
+ [ source] ( http://www.postgresql.org/docs/current/static/sql-altersequence.html )
You can’t perform that action at this time.
0 commit comments