primary-key

Transactional replication with no primary key (unique index)

百般思念 提交于 2020-02-21 13:50:11
问题 I've just come across something disturbing, I was trying to implement transactional replication from a database whose design is not under our control . This replication was in order to perform reporting without taxing the system too much. Upon trying the replication only some of the tables went across. On investigation tables were not selected to be replicated because they don't have a primary key, I thought this cannot be it is even shown as a primary key if I use ODBC and ms access but not

Transactional replication with no primary key (unique index)

余生长醉 提交于 2020-02-21 13:50:09
问题 I've just come across something disturbing, I was trying to implement transactional replication from a database whose design is not under our control . This replication was in order to perform reporting without taxing the system too much. Upon trying the replication only some of the tables went across. On investigation tables were not selected to be replicated because they don't have a primary key, I thought this cannot be it is even shown as a primary key if I use ODBC and ms access but not

VB.Net - How can I check if a primary key exists in an Access DB

陌路散爱 提交于 2020-02-08 07:26:02
问题 I want to check in an Access Database if a primary key exists using VB.Net & OleDb: By primary key name By number of fields as primary keys 回答1: From here: Public Shared Function getKeyNames(tableName As [String], conn As DbConnection) As List(Of String) Dim returnList = New List(Of String)() Dim mySchema As DataTable = TryCast(conn, OleDbConnection).GetOleDbSchemaTable(OleDbSchemaGuid.Primary_Keys, New [Object]() {Nothing, Nothing, tableName}) ' following is a lengthy form of the number '3'

How to update the PRIMARY KEY/FOREIGN KEY in other related tables?

我与影子孤独终老i 提交于 2020-02-07 06:00:06
问题 walls wall_id (P) wall_name wall_views wall_downloads wall_thumbnail_path ( 4, 'wall4', '125', '574', '../.../thumbnail_wall4.jpg' ) types type_id type_name ( '1', 'Desktop' ) ( '2', 'Phone' ) ( '3', 'Tablet' ) wall_types wall_id (P) (F) type_id (P) (F) ( 4, 1 ) Above are the tables I have, what I want to do is automatically get the wall_id = 4 from walls tables and store it in wall_types table, same with the type_id from types table. How can this be done? what is the code (PHP code) or SQL

Issue while creating primary key from gorm model

谁说我不能喝 提交于 2020-01-30 12:09:42
问题 While creating primary key from gorm model it return with error “duplicate column name: “id”” my model looks like type User struct { gorm.Model Id string gorm:"primary_key;" FirstName string LastName string } any idea what is the issue with above model 回答1: Gorm uses ID as the primary key by default. It is part of the gorm.Model you are embedding. When embedding the gorm.Model , you should leave ID out as gorm already includes it. The alternative is to remove the embedded gorm.Model and

MySQL custom primary key generator

一世执手 提交于 2020-01-30 09:29:07
问题 I have written an invoice module for our reservation system. So when I create a new invoice, I automatically generate a primary key through MySQL. However for the moment this is just a simple integer counting up. The problem is that we are obligated to have an invoice number in the form of "#year#id" where #year is e.g. 2013 and #id is an id that start every year back at 1. So e.g. 20131, 20132, 20133 and in 2014 it wil be 20141, 20142. How can I fix this with a custom primary key generator?

Do MySQL tables need an ID? [duplicate]

狂风中的少年 提交于 2020-01-30 04:34:33
问题 This question already has answers here : Closed 8 years ago . Possible Duplicate: Should each and every table have a primary key? If you never refer to the ID anywhere is it necessary to include one? Does a table need an ID or primary key? 回答1: No you do not need a primary key to make a table work in MySQL. That said, a primary key allows for a unique value to refer to a row in a table from another table, or in any code using the table. You do need a primary key to make a table work well in

How large can an id get in postgresql

て烟熏妆下的殇ゞ 提交于 2020-01-29 04:28:07
问题 I am using postgresql, and was wondering how large id INTEGER PRIMARY KEY can get compared to id SERIAL PRIMARY KEY In java an int is 4 bytes (32 bits) so it can get up to 2,147,483,647. Is this the case in postgresql? If so does that mean I cannot go past 2,147,483,647 rows? 回答1: Here is a handy chart for PostgreSQL: Name Storage Size Description Range smallint 2 bytes small-range integer -32768 to +32767 integer 4 bytes usual choice for integer -2147483648 to +2147483647 bigint 8 bytes

Foreign key refering to multiple tables

允我心安 提交于 2020-01-24 17:03:46
问题 I have 4 tables A(ida, name) B(ida, B-specific stuff) C(ida, C-specific stuff) D(ida, D-specific stuff) and i want that another table E could refer to just B OR C (not D). What can i write in the CREATE TABLE E ? 回答1: Seems to me that you are trying to use some kind of supertype/subtype -- as opposed to simple vertical partitioning. If so, do introduce a type-discriminator. Because this is generic example (A, B, C, D ..) it is hard to guess what relates to what, so here are two options as my

integer out of range and remaining disk space too small to convert id to bigint and other solutions

给你一囗甜甜゛ 提交于 2020-01-24 15:04:05
问题 When I insert I am getting integer out of range because my id/primary key was mistakenly created as an int instead of a bigint or bigserial . I tried: ALTER TABLE tbl ALTER COLUMN id TYPE BIGINT; But I get the following error because my free disk space isn't big enough. ERROR: could not extend file "base/16401/3275205": No space left on device HINT: Check free disk space. SQL state: 53100 I can't increase the disk space right now, for frustrating reasons I won't go into. I also tried reusing