About 440,000 results
Open links in new tab
  1. How do I create a foreign key in SQL Server? - Stack Overflow

    I have never "hand-coded" object creation code for SQL Server and foreign key decleration is seemingly different between SQL Server and Postgres. Here is my sql so far: drop table …

  2. What is the difference between primary, unique and foreign key ...

    Nov 7, 2009 · Foreign Key: A foreign key (sometimes called a referencing key) is a key used to link two tables together. Typically you take the primary key field from one table and insert it …

  3. sql - PostgreSQL Foreign Key syntax - Stack Overflow

    Feb 17, 2015 · There are four different ways to define a foreign key (when dealing with a single column PK) and they all lead to the same foreign key constraint: Inline without mentioning the …

  4. Can a foreign key be NULL and/or duplicate? - Stack Overflow

    Mar 11, 2017 · By default there are no constraints on the foreign key, foreign key can be null and duplicate. while creating a table / altering the table, if you add any constrain of uniqueness or …

  5. mysql - ERROR 1452: Cannot add or update a child row: a foreign …

    Feb 9, 2014 · Taken from Using FOREIGN KEY Constraints Foreign key relationships involve a parent table that holds the central data values, and a child table with identical values pointing …

  6. Is it fine to have foreign key as primary key? - Stack Overflow

    Jun 11, 2012 · It is perfectly fine to use a foreign key as the primary key if the table is connected by a one-to-one relationship, not a one-to-many relationship. If you want the same user record …

  7. How to add foreign key in PostgreSQL - Stack Overflow

    Aug 23, 2021 · 49 Name column in author table is primary key and it's referenced as foreign key in bookstore table.

  8. sql - can we have a foreign key which is not a primary key in any …

    May 24, 2010 · By definition a foreign key must reference a candidate key of some table. It doesn't necessarily have to be the primary key. As a matter of detail the constraint called a …

  9. How to find foreign key dependencies in SQL Server?

    May 29, 2009 · How can I find all of the foreign key dependencies on a particular column? What are the different alternatives (graphically in SSMS, queries/views in SQL Server, 3rd party …

  10. postgresql - How to add a column with a foreign key constraint to …

    Mar 12, 2016 · ALTER TABLE message ADD FOREIGN KEY (sender) REFERENCES users; It would be a "nice-to-have" if the RDBMS could automatically create the field you want with the …