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 656977
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T22:46:23+00:00 2026-05-13T22:46:23+00:00

I need to add a NOT NULL column to an existing (populated) table that

  • 0

I need to add a NOT NULL column to an existing (populated) table that will be a foreign key to another table. This brings about two problems:

  1. When you add the column, its value cannot be null – using a default is not an option (unless it is removed later on) because the database logic is used in the server side validation when a user enters a new record i.e. when the application tries to add a record with this field having a null value, the database throws an error that the application catches and returns to the user, prompting them to correct it.

  2. The column has a foreign key constraint, meaning its value MUST exist in the foreign table as well.

What is the best way to go about this?

  • 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-13T22:46:24+00:00Added an answer on May 13, 2026 at 10:46 pm

    Create the column, but allow NULL.
    Populate the column with the correct data from the foreign key table.
    Alter the column add not null.
    Add the foreign key constraint.

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

Sidebar

Related Questions

To add a NOT NULL Column to a table with many records, a DEFAULT
I need to add checked items from one checklistbox to another. I should not
I have this SQL table: CREATE TABLE DATA ( ID NUMBER NOT NULL, CODE
I need to ALTER my existing database to add a column. Consequently I also
Is there a way to add a not null type column to a Postgresql
I need to add an auto increment id to an already existing table. I
If I run the following query: ALTER TABLE `price_s` ADD COLUMN `ts` TIMESTAMP NOT
I need to add a user profile variable in java, apparently %userprofile% does not
I have a dataGrid(not dataGridView) in which i need to add Checkbox dynamically at
I need add Auto complete on apex Tabular Form. there is a column as

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.