Skip to main content

ERROR 1138 (22004): Invalid use of NULL value

Reproducing:

  1. Get a table with values.
  2. Add a new column with null value availability.
  3. Modify the same column to be 'not null'.
Fix:
  1. Change column value for all records to non null value.
  2. Modify the column to 'not null'.

Comments

Popular posts from this blog

session_start(): Failed to initialize storage module: user (path: )

Error: session_start(): Failed to initialize storage module: user (path: ) Solution: When this error is given for the Codeigniter project you are running, that is specifically for not having a path recognised to store session data. Set config data as follows [file: your-project-folder/application/config/config.php] : $config['sess_driver'] = 'files'; $config['sess_cookie_name'] = 'ci_session'; $config['sess_expiration'] = 7200; $config['sess_save_path'] = APPPATH.'cache/'; $config['sess_match_ip'] = TRUE; $config['sess_time_to_update'] = 300; $config['sess_regenerate_destroy'] = FALSE;

Get related keys of a table

terminal->mysql SELECT TABLE_NAME,COLUMN_NAME,CONSTRAINT_NAME, REFERENCED_TABLE_NAME,REFERENCED_COLUMN_NAME FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE WHERE REFERENCED_TABLE_SCHEMA = '<database>' AND REFERENCED_TABLE_NAME = '<table>' With Column terminal->mysql SELECT TABLE_NAME,COLUMN_NAME,CONSTRAINT_NAME, REFERENCED_TABLE_NAME,REFERENCED_COLUMN_NAME FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE WHERE REFERENCED_TABLE_SCHEMA = '<database>' AND REFERENCED_TABLE_NAME = '<table>' AND REFERENCED_COLUMN_NAME = '<column>';