Skip to content

Commit 3e599c4

Browse files
committed
Add Restart A Sequence as a postgres til.
1 parent c7de4cf commit 3e599c4

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ smart people at [Hashrocket](http://hashrocket.com/).
121121
- [List All Columns Of A Specific Type](postgres/list-all-columns-of-a-specific-type.md)
122122
- [List All Versions Of A Function](postgres/list-all-versions-of-a-function.md)
123123
- [List Database Users](postgres/list-database-users.md)
124+
- [Restart A Sequence](postgres/restart-a-sequence.md)
124125
- [Send A Command To psql](postgres/send-a-command-to-psql.md)
125126
- [Special Math Operators](postgres/special-math-operators.md)
126127
- [String Contains Another String](postgres/string-contains-another-string.md)

postgres/restart-a-sequence.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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)

0 commit comments

Comments
 (0)