Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6531261
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T09:51:24+00:00 2026-05-25T09:51:24+00:00

In the following table definition, what is the difference between these two column definitions,

  • 0

In the following table definition, what is the difference between these two column definitions, or does the second just create an automatically named foreign key index?

CREATE TABLE dbo.Employee
(
    dept_id     int  NOT NULL  
        CONSTRAINT fk_employee_deptid FOREIGN KEY REFERENCES Department(dept_id),
    empType_id  int  NOT NULL  REFERENCES  EmployeeType(empType_id)
    /* ... other columns ... */
);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T09:51:24+00:00Added an answer on May 25, 2026 at 9:51 am

    The only difference is that the second one will be given a system generated name that will likely be more cryptic than one you allocate yourself.

    The column name is also optional where there is an unambiguous possibility.

    empType_id  int  NOT NULL  REFERENCES  EmployeeType
    

    can also work. Again no difference in the end result. The full grammar for the FK declaration is

    [ CONSTRAINT constraint_name ] 
    {      [ FOREIGN KEY ] 
            REFERENCES [ schema_name . ] referenced_table_name [ ( ref_column ) ] 
            [ ON DELETE { NO ACTION | CASCADE | SET NULL | SET DEFAULT } ] 
            [ ON UPDATE { NO ACTION | CASCADE | SET NULL | SET DEFAULT } ] 
            [ NOT FOR REPLICATION ] 
     } 
    

    Optional items are enclosed in square brackets.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

With the following (simplified) MySQL table definitions: create table items ( item_id int unsigned
The following table definition: CREATE TABLE Customers( id INT NOT NULL PRIMARY KEY, name
One of my tables has the following definition: CREATE TABLE incidents ( id serial
I have the following table definition: CREATE TABLE X ( A SOMETYPE NOT NULL,
I have the following table definition for journal CREATE TABLE public.journal ( id public.inc_journal
Suppose I have the following table definition: CREATE TABLE x (i serial primary key,
I have the following table schema; CREATE TABLE `db1`.`sms_queue` ( `Id` INTEGER UNSIGNED NOT
I have the following table structure CREATE TABLE `table` ( `id` int(11) NOT NULL
Assume a table definition in SQL Server as follows: CREATE TABLE MyTable ( Id
I have a table with with 7,526,511 records with the following definition: /****** Object:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.