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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T12:12:42+00:00 2026-06-05T12:12:42+00:00

I have created a database table like this: CREATE TABLE test( name VARCHAR(30) NOT

  • 0

I have created a database table like this:

CREATE TABLE test(
  name VARCHAR(30) NOT NULL, 
  password VARCHAR(40) NOT NULL);

I then added to it like this, which failed as expected.

INSERT INTO test(name, password) VALUES ('test', NULL);

But then when I tried this it inserted without a problem:

INSERT INTO test(name) VALUES ('test');

I tried to create the table differently but it didn’t create:

CREATE TABLE test(
 name VARCHAR(30) NOT NULL, 
 password VARCHAR(40) NOT NULL DEFAULT NULL );

So is there a way to get that to create an error when inserting?

Perhaps associated I think I will need to do something else to be able to validate data input into the database anyway and I think I saw something about constraints but I don’t think these are supported in mysql? So is the null check and validation something I can’t do the database with mysql?

  • 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-06-05T12:12:44+00:00Added an answer on June 5, 2026 at 12:12 pm

    By default, MySQL replaces implicit NULL values with zeroes (or empty strings for string datatypes).

    You can work around this by enabling strict mode for your session or server:

    SET sql_mode='STRICT_ALL_TABLES'
    

    or add

    sql_mode='STRICT_ALL_TABLES'
    

    under [mysqld] in your my.cnf.

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

Sidebar

Related Questions

I have mysql database structure like below: CREATE TABLE test ( id int(11) NOT
Say I have a table like so: CREATE TABLE big_table (UUID varchar(32) not null,
I have created a table on an Oracle 10g database with this structure :
I have the following code to create a database table if it does not
I have 2 tables in my mysql database: CREATE TABLE IF NOT EXISTS `RECIPES`
I have a database that looks like this: ID parent name description _record_status _log_user
I have names stored in my mysql database i created a table called users
I have the following table in a SQLite3 database: CREATE TABLE overlap_results ( neighbors_of_annotation
I have the following table and sequence in my postgresql-8.4 database: CREATE TABLE complexobjectpy
i'm having a problem with my database. I have the folowing: create table book

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.