primary-key

Oracle SQL: Receiving 'no matching unique or primary key' error and don't know why

别来无恙 提交于 2019-12-14 03:54:46
问题 I'm receiving this error when trying to create a table and I don't know why: [2016-07-05 14:08:02] [42000][2270] ORA-02270: no matching unique or primary key for this column-list This question seems different (to me) from a similar question, because in that question the OP is referencing a table with a composite PK, while I am not. And while this other question has the same error code, it is because the OP is incorrectly references the primary key, which I don't think I did. May someone more

Join three tables with one of them not having a primary key

蹲街弑〆低调 提交于 2019-12-14 03:06:13
问题 I have three tables that i would like to join up together. Domain table -domainid - Primary key DomainRegion table -domainid - Don't have a Primary Key or Foreign Key -dombegin -domend DynDomrun table -ddid - Primary Key -confid1 -confid2 "domain.domainid", "domainregion.domainid" and "dyndomrun.ddid" have the same type of data types, "character varying". Now, the problem is that "domain.domainid" and "domainregion.domainid" has two extra characters in it that i can't seem to do a join with

Referencing the foreign key of another schema

岁酱吖の 提交于 2019-12-14 02:16:44
问题 For my project I am using oracle database where I have to work with 2 different database schema. Consider the following scenario please - I have a schema A and in it I have a table table_a with a primary key apk And I have another schema B and in it I have a table table_b with a primary key bpk If both of these tables are in a same database then I can easily make a primary key - foreign key relationship. But can I make a primary key - foreign key relation ship (or something like this) between

Create a unique primary key (hash) from database columns

不打扰是莪最后的温柔 提交于 2019-12-13 16:22:50
问题 I have this table which doesn't have a primary key. I'm going to insert some records in a new table to analyze them and I'm thinking in creating a new primary key with the values from all the available columns. If this were a programming language like Java I would: int hash = column1 * 31 + column2 * 31 + column3*31 Or something like that. But this is SQL. How can I create a primary key from the values of the available columns? It won't work for me to simply mark all the columns as PK, for

Identity column Vs Primary Key [closed]

被刻印的时光 ゝ 提交于 2019-12-13 14:06:31
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 7 years ago . How can we decide on to go with Identity column or Primary Key? 回答1: The two concepts are not mutually exclusive. All combinations are possible: An identity column that is also a primary key, An identity column

Resetting Primary key without deleting truncating table

浪尽此生 提交于 2019-12-13 12:29:30
问题 I have a table with a primary key, now without any reason I don't know when I am inserting data it is being loaded like this Pk_Col Some_Other_Col 1 A 2 B 3 C 1002 D 1003 E 1901 F Is there any way I can reset my table like below, without deleting/ truncating the table? Pk_Col Some_Other_Col 1 A 2 B 3 C 4 D 5 E 6 F 回答1: You can't update the IDENTITY column so DELETE/INSERT is the only way. You can reseed the IDENTITY column and recreate the data, like this: DBCC CHECKIDENT ('dbo.tbl',RESEED,0)

SQLAlchemy with multiple primary keys does not automatically set any

时间秒杀一切 提交于 2019-12-13 12:09:51
问题 I had a simple table: class test(Base): __tablename__ = 'test' id = Column(Integer, primary_key=True) title = Column(String) def __init__(self, title): self.title = title When using this table, id was set automatically. I want to add another field that is unique and efficient to search, so I added the field: id2 = Column(String, primary_key=True) And updated the constructor: def __init__(self, id2, title): self.id2 = id2 self.title = title Now, id is no longer automatically set, or rather I

What is the PK and FK i should assign to my table?

假如想象 提交于 2019-12-13 10:08:14
问题 A company provides transport services to high-ranked staffs. There are 3 tables: DRIVERS, VEHICLES, STAFFS. DRIVERS - license number [PK] - name - language spoken - ... (and so on..) VEHICLES - vehicle ID [PK] - registration number - model - colour - ... and so on... STAFFS - staff ID [PK] - name - position name - ... and so on.... I want to create a new table called ORGANIZE whereby, it will assign a driver and a vehicle to match the needs of the staff. what will be the PK and FKs? 回答1: I've

Duplicate entry for primary key on MySQL

别说谁变了你拦得住时间么 提交于 2019-12-13 08:59:53
问题 My table just has single column ID (passwords for admin Log-in) Because this code runs every time that program starts, I can prevent errors occurs on creating database and creating tables by using IF NOT EXIXTS statement. Since adminLogin table should be initial first time, When user re-run the program, the Duplicate entry for primary key error occurs. I used IF NOT EXISTS for inserting into table, But there is some another error! My table: Error: 回答1: You are trying to insert same value. PK

Postgresql table with one ID column, sorted index, with duplicate primary key

淺唱寂寞╮ 提交于 2019-12-13 08:34:39
问题 I want to use a PostgreSQL table as a kind of work queue for documents. Each document has an ID and is stored in another, normal table with lots of additional columns. But this question is about creating the table for the work queue. I want to create a table for this queue without OIDs with just one column: The ID of the document as integer. If an ID of a document exists in this work queue table, it means that the document with that ID is dirty and some processing has to be done. The extra