Questions tagged [sequence]

A sequence is an ordered list of objects (or events). Like a set, it contains members (also called elements or terms), and the number of terms (possibly infinite) is called the length of the sequence. Unlike a set, order matters, and exactly the same elements can appear multiple times at different positions in the sequence. In a relational database, a sequence is an object that is used to generate unique numbers for a primary key.

A sequence is an ordered list of objects (or events). Like a set, it contains members (also called elements or terms), and the number of terms (possibly infinite) is called the length of the sequence. Unlike a set, order matters, and exactly the same elements can appear multiple times at different positions in the sequence.

Sometimes, sequence is used as a generic name for both list, array and set for convenience.

In a , a sequence is an object that is used to generate unique numbers for a .

5959 questions
4512
votes
38 answers

How slicing in Python works

How does Python's slice notation work? That is: when I write code like a[x:y:z], a[:], a[::2] etc., how can I understand which elements end up in the slice? Please include references where appropriate. See Why are slice and range upper-bound…
Simon
  • 78,655
  • 25
  • 88
  • 118
708
votes
7 answers

How can I get the concatenation of two lists in Python without modifying either one?

In Python, the only way I can find to concatenate two lists is list.extend, which modifies the first list. Is there any concatenation function that returns its result without modifying its arguments?
Ryan C. Thompson
  • 40,856
  • 28
  • 97
  • 159
231
votes
4 answers

Why does PostgreSQL perform sequential scan on indexed column?

Very simple example - one table, one index, one query: CREATE TABLE book ( id bigserial NOT NULL, "year" integer, -- other columns... ); CREATE INDEX book_year_idx ON book (year) EXPLAIN SELECT * FROM book b WHERE b.year > 2009 gives…
Alex Vayda
  • 6,154
  • 5
  • 34
  • 50
206
votes
16 answers

How to reset sequence in postgres and fill id column with new data?

I have a table with over million rows. I need to reset sequence and reassign id column with new values (1, 2, 3, 4... etc...). Is any easy way to do that?
sennin
  • 8,552
  • 10
  • 32
  • 47
202
votes
18 answers

How do I reset a sequence in Oracle?

In PostgreSQL, I can do something like this: ALTER SEQUENCE serial RESTART WITH 0; Is there an Oracle equivalent?
Mauli
  • 16,863
  • 27
  • 87
  • 114
197
votes
8 answers

How to retrieve the current value of an oracle sequence without increment it?

Is there an SQL instruction to retrieve the value of a sequence that does not increment it. Thanks. EDIT AND CONCLUSION As stated by Justin Cave It's not useful to try to "save" sequence number so select a_seq.nextval from dual; is good enough to…
frno
  • 2,641
  • 2
  • 18
  • 19
160
votes
23 answers

Hibernate JPA Sequence (non-Id)

Is it possible to use a DB sequence for some column that is not the identifier/is not part of a composite identifier? I'm using hibernate as jpa provider, and I have a table that has some columns that are generated values (using a sequence),…
Miguel Ping
  • 18,082
  • 23
  • 88
  • 136
154
votes
7 answers

Fixing the order of facets in ggplot

Data: df <- data.frame( type = c("T", "F", "P", "T", "F", "P", "T", "F", "P", "T", "F", "P"), size = c("50%", "50%", "50%", "100%", "100%", "100%", "150%", "150%", "150%", "200%", "200%", "200%"), amount = c(48.4, 48.1, 46.8, 25.9,…
samarasa
  • 2,025
  • 2
  • 16
  • 22
144
votes
16 answers

Sequence-zip function for C++11?

With the new range-based for-loop we can write code like: for(auto x: Y) {} Which IMO is a huge improvement from (for ex.) for(std::vector::iterator x=Y.begin(); x!=Y.end(); ++x) {} Can it be used to loop over two simultaneous loops, like…
Hooked
  • 84,485
  • 43
  • 192
  • 261
131
votes
9 answers

How to create a sequence of integers in C#?

F# has sequences that allows to create sequences: seq { 0 .. 10 } Create sequence of numbers from 0 to 10. Is there something similar in C#?
Budda
  • 18,015
  • 33
  • 124
  • 206
125
votes
9 answers

Create a group number for each consecutive sequence

I have the data.frame below. I want to add a column 'g' that classifies my data according to consecutive sequences in column h_no. That is, the first sequence of h_no 1, 2, 3, 4 is group 1, the second series of h_no (1 to 7) is group 2, and so on,…
Susanne Dreisigacker
  • 1,251
  • 2
  • 9
  • 3
114
votes
5 answers

Get number of items from list (or other iterable) with certain condition

Assuming that I have a list with a huge number of items, l = [ 1, 4, 6, 30, 2, ... ] I want to get the number of items from that list, where an item satisfies a certain condition. My first thought was: count = len([i for i in l if…
cinsk
  • 1,576
  • 2
  • 12
  • 14
109
votes
11 answers

UUID performance in MySQL?

We're considering using UUID values as primary keys for our MySQL database. The data being inserted is generated from dozens, hundreds, or even thousands of remote computers and being inserted at a rate of 100-40,000 inserts per second, and we'll…
Patrick Lightbody
  • 4,424
  • 2
  • 28
  • 38
108
votes
5 answers

Clojure: cons (seq) vs. conj (list)

I know that cons returns a seq and conj returns a collection. I also know that conj "adds" the item to the optimal end of the collection, and cons always "adds" the item to the front. This example illustrates both of these points: user=> (conj [1…
dbyrne
  • 59,111
  • 13
  • 86
  • 103
96
votes
3 answers

Create a Vector of All Days Between Two Dates

Is there an easy way in R for me to itemize all valid days that occurred between two specified dates? For instance, I'd like the following inputs: itemizeDates(startDate="12-30-11", endDate="1-4-12") To produce the following dates: "12-30-11"…
Jeff Allen
  • 17,277
  • 8
  • 49
  • 70
1
2 3
99 100