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
48
votes
8 answers

PostgreSQL next value of the sequences?

I am using PostgreSQL for my Codeigniter website. I am using grocery crud for add, edit and delete operations. While doing an edit or add, I want to rename an uploaded file dynamically based on the id of the content. I am able to do this using…
i_nomad
  • 795
  • 2
  • 7
  • 9
47
votes
8 answers

How to create an Oracle sequence starting with max value from a table?

Trying to create a sequence in Oracle that starts with the max value from a specific table. Why does this not work? CREATE SEQUENCE transaction_sequence MINVALUE 0 START WITH (SELECT MAX(trans_seq_no) FROM TRANSACTION_LOG) INCREMENT BY…
Amar Premsaran Patel
  • 1,293
  • 7
  • 17
  • 26
47
votes
5 answers

Clojure: Semi-Flattening a nested Sequence

I have a list with embedded lists of vectors, which looks like: (([1 2]) ([3 4] [5 6]) ([7 8])) Which I know is not ideal to work with. I'd like to flatten this to ([1 2] [3 4] [5 6] [7 8]). flatten doesn't work: it gives me (1 2 3 4 5 6 7 8). How…
ChucK
  • 2,114
  • 1
  • 18
  • 20
47
votes
9 answers

Generate a sequence of numbers in Python

How can I generate the sequence of numbers "1,2,5,6,9,10......" and so until 100 in Python? I even need the comma (',') included, but this is not the main problem. The sequence: every number from 1..100, divisible by 4 with remainder 1 or 2.
user1460818
  • 491
  • 1
  • 4
  • 4
46
votes
2 answers

Sequence Permission in Oracle

How can I check a permission granted for particular sequence and assign permission to particular sequence from SQL*Plus?
Jack
  • 785
  • 4
  • 12
  • 19
45
votes
7 answers

XML Entity for "/"?

So I'm writing some XML generating code, and found that the following attribute value was screwing up the XML formatting: "Jim/Bob" So I looked into the XML Entities used as escape sequences and every list I saw did not include one for the forward…
Alpants
  • 766
  • 2
  • 8
  • 19
43
votes
1 answer

How to choose between UUIDs, autoincrement/sequence keys and sequence tables for database primary keys?

I'm looking at the pros and cons of these three primary methods of coming up with primary keys for database rows. So assuming I am using a database that supports more than one of these methods, is there a simple heuristic to determine what the best…
Tim
  • 6,851
  • 11
  • 42
  • 46
43
votes
13 answers

Permutation algorithm without recursion? Java

I would like to get all combination of a number without any repetition. Like 0.1.2, 0.2.1, 1.2.0, 1.0.2, 2.0.1, 2.1.0. I tried to find an easy scheme, but couldn't. I drew a graph/tree for it and this screams to use recursion. But I would like to do…
Andreas Hornig
  • 2,439
  • 5
  • 28
  • 36
42
votes
2 answers

Oracle SQL: Use sequence in insert with Select Statement

Basically I want to run the following query: INSERT INTO historical_car_stats (historical_car_stats_id, year, month, make, model, region, avg_msrp, count) SELECT my_seq.nextval, '2010', '12', 'ALL', 'ALL', region, …
Muhd
  • 24,305
  • 22
  • 61
  • 78
42
votes
5 answers

Generate a sequence of characters from 'A'-'Z'

I can make a sequence of numbers like this: s = seq(from=1, to=10, by=1) How do I make a sequence of characters from A-Z? This doesn't work: seq(from=1, to=10)
James Thompson
  • 46,512
  • 18
  • 65
  • 82
41
votes
6 answers

How can I determine all possible ways a subsequence can be removed from a sequence?

Given two sequences, A and B, how can I generate a list of all the possible ways that B can be removed from A? For example, In JavaScript, if I had a function removeSubSeq taking two array arguments that did what I want, it would work as…
heenenee
  • 19,914
  • 1
  • 60
  • 86
41
votes
6 answers

How do I create a sequence in MySQL?

I'm trying to create a sequence in MySQL (I'm very new to SQL as a whole). I'm using the following code, but it causes an error: CREATE SEQUENCE ORDID INCREMENT BY 1 START WITH 622; ORDID refers to a field in a table I'm using. How do I create the…
Ben
  • 1,299
  • 3
  • 17
  • 37
40
votes
7 answers

Sequence does not reset after truncating the table

I use SELECT lastval() to get wrong serial id after truncated the table. when I truncate the table, I use SELECT lastval(), I got the wrong ID/
user1369887
  • 491
  • 1
  • 6
  • 10
39
votes
1 answer

rep() with each equals a vector

I have quick question regarding sequence and each: vect1 <- c(4, 5, 10, 3, 1) I want replicate with this vector as each such that first number is replicated 4, second 5, third 10, fourth 3, and fifth equal 1. rep(1:5, each = vect1) [1] 1 1 1 1 2…
jon
  • 11,186
  • 19
  • 80
  • 132
39
votes
5 answers

Difference between list, sequence and slice in Python?

What are the differences between these built-in Python data types: list, sequence and slice? As I see it, all three essentially represent what C++ and Java call array.
Tony the Pony
  • 40,327
  • 71
  • 187
  • 281