primary-key Questions
10
I was working on an Access database which loved auto-numbered identifiers. Every table used them except one, which used a key made up of the first name, last name and birthdate of a person. Anyways...
Jubal asked 18/8, 2010 at 13:59
15
Solved
I'm using Rails migrations to manage a database schema, and I'm creating a simple table where I'd like to use a non-integer value as the primary key (in particular, a string). To abstract away from...
Painter asked 29/7, 2009 at 14:15
9
Solved
I have inserted a row with some data in a table where a primary key is present. How would one "SELECT" the primary key of the row one just inserted?
I should have been more specific and ...
Middlebrooks asked 12/12, 2011 at 18:51
4
Solved
I have a table user_interactions with 4 columns:
user_1
user_2
type
timestamp
The primary key is (user_1,user_2,type)
and I want to change to (user_2,user_1,type)
So what I did was :
dr...
Thomey asked 26/2, 2010 at 12:42
10
Solved
I was wondering if anybody knew a good way to create a unique random integer id for a primary key for a table. I'm using MySQL. The value has to be integer.
Smail asked 19/11, 2010 at 14:13
12
Solved
I started by googling and found the article How to write INSERT if NOT EXISTS queries in standard SQL which talks about mutex tables.
I have a table with ~14 million records. If I want to add more ...
Stadiometer asked 1/9, 2009 at 8:56
10
Solved
I have a table Messages with columns ID (primary key, autoincrement) and Content (text).
I have a table Users with columns username (primary key, text) and Hash.
A message is sent by one Sender (us...
Arlon asked 24/1, 2010 at 13:7
13
Solved
I have the following table schema which maps user_customers to permissions on a live MySQL database:
mysql> describe user_customer_permission;
+------------------+---------+------+-----+-------...
Misgive asked 21/1, 2010 at 17:20
7
Solved
Here is a table in MySQL 5.3.X+ db:
CREATE TABLE members` (
`id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
`memberid` VARCHAR( 30 ) NOT NULL ,
`Time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAM...
Sicken asked 13/11, 2011 at 20:35
4
Solved
I try to update the PK in Django with the .save() method, but when I save the object, Django duplicates the object with the same data but a different PK. For example:
from gestion_empleados.Models ...
Tammietammuz asked 15/4, 2015 at 17:51
7
Solved
I have a table with existing data. Is there a way to add a primary key without deleting and re-creating the table?
Ukase asked 31/5, 2010 at 15:31
20
Solved
I am using MySQL 5.1.56, MyISAM. My table looks like this:
CREATE TABLE IF NOT EXISTS `my_table` (
`number` int(11) NOT NULL,
`name` varchar(50) NOT NULL,
`money` int(11) NOT NULL,
PRIMARY KEY...
Hebraic asked 30/10, 2012 at 4:13
5
Solved
I have a table in postgres whose primary key is assinged using a sequence (let's call it 'a_seq'). The sequence is for incrementing the value and inserting the current value as primary key of recor...
Marrin asked 6/4, 2018 at 7:8
3
Solved
I have 2 tables, User and Employee. Each user is given a User_ID and that is a primary key in the User table and a foreign key in the Employee table. Can that attribute in the Employee table also b...
Refresh asked 11/2, 2012 at 22:2
2
Solved
According to the SQLite documentation / FAQ a column declared INTEGER PRIMARY KEY will automatically get a value of +1 the highest of the column if omitted.
Using SQLite version 3.22.0 2018-01-22 1...
Auction asked 1/3, 2018 at 17:52
10
Solved
I am trying to create a table with an auto-incrementing primary key in Sqlite3. I am not sure if this is really possible, but I am hoping to only have to designate the other fields.
For example:
CR...
Hypogynous asked 26/10, 2011 at 16:36
2
Solved
This does not execute:
create table TestTable (name text, age integer, primary key (ROWID))
The error message is:
11-23 11:05:05.298: ERROR/Database(31335): Failure 1 (table TestTable has no ...
Yoruba asked 23/11, 2011 at 17:38
8
Solved
I inherited a project and I'm running into a SQL error that I'm not sure how to fix.
On an eCommerce site, the code is inserting order shipping info into another database table.
Here's the code tha...
Spelter asked 16/3, 2016 at 17:59
35
Solved
I ran into the problem that my primary key sequence is not in sync with my table rows.
That is, when I insert a new row I get a duplicate key error because the sequence implied in the serial data...
Smaragd asked 28/10, 2008 at 18:8
12
I have an existing table called Person which already has existing 1000 rows of data. In this table I have 5 fields:
personId
Pname
PMid
Pdescription
Pamt
The table already has an existing compoun...
Phosphorus asked 3/8, 2012 at 11:17
9
Solved
For some reason, people in the past have inserted data without using sequence.NEXTVAL. So when I go to use sequence.NEXTVAL in order to populate a table, I get a PK violation, since that number is ...
Fragonard asked 23/5, 2011 at 15:8
7
Solved
Is it bad to have text as a primary key in an SQLite database? I heard that it's bad for performance reasons, is this true? And will the rowid be used as the actual primary key in such a case...
Romanticist asked 18/4, 2014 at 15:40
5
Solved
What is the difference between a primary key and an index key?
When do I use each?
Thwack asked 21/3, 2011 at 7:31
7
Solved
How would I reset the primary key counter on a sql table and update each row with a new primary key?
Nunatak asked 23/10, 2008 at 14:42
9
When should I use KEY, PRIMARY KEY, UNIQUE KEY and INDEX?
Caldarium asked 2/10, 2010 at 8:5
1 Next >
© 2022 - 2025 — McMap. All rights reserved.