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

  • Home
  • SEARCH
  • 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 7530535
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T04:56:14+00:00 2026-05-30T04:56:14+00:00

There is something wrong with DEFAULT keyword handling Example: CREATE TABLE BAR(c1 int null,c2

  • 0

There is something wrong with DEFAULT keyword handling

Example:

 CREATE TABLE BAR(c1 int null,c2 int default 1 not null)

Executing SQL like this:

 INSERT INTO BAR SET c1 = 1, c2 = COALESCE(null,DEFAULT)

Results in:
Column “DEFAULT” not found; SQL statement:
INSERT INTO BAR SET c1 = 1, c2 = COALESCE(null,DEFAULT) [42122-161]
42S22/42122

At the same time:

INSERT INTO BAR (c1,c2) values (1,  DEFAULT)

Ok!

But,

 INSERT INTO BAR SET c1 = 1, c2  = DEFAULT

Result:
NULL not allowed for column “C2”; SQL statement:
INSERT INTO BAR SET c1 = 1, c2 = DEFAULT [23502-161] 23502/23502

I think it is a bug. If it is not, is any way to specify use of
default value exists?

H2 1.3.161 (2011-10-28)

  • 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-30T04:56:15+00:00Added an answer on May 30, 2026 at 4:56 am

    The term DEFAULT isn’t a pseudo-column or an expression that can be used in a formula. DEFAULT is used instead of an expression. I tried MySQL and it works in the same way as H2.

    drop table foo cascade;
    CREATE TABLE FOO(c1 int null,c2 int default 1 not null);
    INSERT INTO FOO SET c1 = 1, c2 = default; -- works
    INSERT INTO FOO SET c1 = 1, c2 = default * 2; -- doesn't work
    

    What you probably want is use a parameterized statement (right?) where NULL is converted to default. H2 does support this, but it’s not fully documented. You can use:

    drop table foo cascade;
    CREATE TABLE FOO(c1 int null,c2 int default 1 not null null_to_default);
    INSERT INTO FOO SET c1 = 1, c2 = null;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

There's something wrong with my code or I'm just not understanding this fully. I
There is something wrong with this trigger. But what? CREATE TRIGGER MYCOOLTRIGGER AFTER INSERT
Are methods calls really so slow or is there something wrong in my computer?
I wonder if there is something wrong with the copy constructor function below? class
Is there something like Python's getattr() in C#? I would like to create a
Is there something fundamentally wrong with the following design, or can anyone see why
Is there something wrong in what the repository, http://teleal.org/m2 , returns? This is my
I'm pretty sure there's something wrong with this part of a switch statement, but
It's my first time I'm using ComboPooledDataSource in hibernate, but there's something wrong with
There's obviously something wrong with my build, but I can't figure it out. I

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.