0

When inserting rows in table, a default value is a NULL. Is their a way to make

"<null>"

such that,

+--------------+-------------+------+-----+-------------------+----------------+
| Field        | Type        | Null | Key | Default           | Extra          |
+--------------+-------------+------+-----+-------------------+----------------+
| id           | int(11)     | NO   | PRI | NULL              | auto_increment |
| prev_id      | int(11)     | YES  |     | NULL              |                |
| package      | text        | YES  |     | NULL              |                |
| app          | text        | YES  |     | NULL              |                |
+--------------+-------------+------+-----+-------------------+----------------+

looks like this.

+--------------+-------------+------+-----+-------------------+----------------+
| Field        | Type        | Null | Key | Default           | Extra          |
+--------------+-------------+------+-----+-------------------+----------------+
| id           | int(11)     | NO   | PRI | <null>            | auto_increment |
| prev_id      | int(11)     | YES  |     | <null>            |                |
| package      | text        | YES  |     | <null>            |                |
| app          | text        | YES  |     | <null>            |                |
+--------------+-------------+------+-----+-------------------+----------------+
3
  • What?! Why? What are you trying to achieve? This is mysql I assume? (please tag as such). How are you inserting?
    – danblack
    Apr 24, 2020 at 4:21
  • 1
    estimate of an answer, leave formatting of NULL values to the application layer. If really needed at SQL layer, SELECT COALESE(prev_id, '<null>') as prev_id .. on retrieval.
    – danblack
    Apr 24, 2020 at 4:29
  • Yon can declare the column like: package text default '<null>' For prev_id thats not possible of course Apr 24, 2020 at 17:36

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.