ホーム > 未分類 > [MySQL] NOT NULLかつDEFAULTなしの列を追加した場合、データタイプデフォルト値が設定される。

[MySQL] NOT NULLかつDEFAULTなしの列を追加した場合、データタイプデフォルト値が設定される。

MySQL(5.0系)で、すでにレコードが存在するテーブルにNOT NULLかつDEFAULTなしの列を追加してもエラーにならなかった。きちんと理解していないので調べておく。

以下のテーブルを作成し、レコードを追加しておく。

mysql> CREATE TABLE users (id INTEGER PRIMARY KEY);
mysql> DESC users;
+-------+---------+------+-----+---------+----------------+
| Field | Type    | Null | Key | Default | Extra          |
+-------+---------+------+-----+---------+----------------+
| id    | int(11) | NO   | PRI | NULL    |                | 
+-------+---------+------+-----+---------+----------------+
mysql> INSERT INTO users VALUES(1);

NOT NULLでDEFAULTなしの列を追加してみる。

mysql> ALTER TABLE users ADD (name VARCHAR(255) NOT NULL, 
age INTEGER NOT NULL, created_at DATETIME NOT NULL);

エラーにならず、以下の値が設定された。

mysql> SELECT * FROM USERS;
+----+------+-----+---------------------+
| id | name | age | created_at          |
+----+------+-----+---------------------+
|  1 |      |   0 | 0000-00-00 00:00:00 | 
+----+------+-----+---------------------+

どうやら「データタイプデフォルト値」が設定されるもよう。
これは「ストリクトSQLモード」が有効な場合でも同じ結果となる。試してみる。

-- いったん列を削除
mysql> ALTER TABLE users DROP name;
mysql> ALTER TABLE users DROP age;
mysql> ALTER TABLE users DROP created_at;
 
-- ストリクトSQLモードを有効に
mysql> SET sql_mode = 'STRICT_ALL_TABLES';
mysql> SELECT @@sql_mode;
+-------------------+
| @@sql_mode        |
+-------------------+
| STRICT_ALL_TABLES | 
+-------------------+
 
-- ストリクトSQLモードでもエラーにならない
mysql> ALTER TABLE users ADD (name VARCHAR(255) NOT NULL, 
age INTEGER NOT NULL, created_at DATETIME NOT NULL);
mysql> SELECT * FROM USERS;
+----+------+-----+---------------------+
| id | name | age | created_at          |
+----+------+-----+---------------------+
|  1 |      |   0 | 0000-00-00 00:00:00 | 
+----+------+-----+---------------------+

せめてストリクトSQLモードが有効な場合にはエラーにしてほしいですね。要注意です。

参照ドキュメント:

カテゴリー: 未分類 タグ:
  1. 2020 年 4 月 2 日 12:47 | #1

    free casino games casino slots vegas slots online casino game

  2. 2020 年 4 月 2 日 12:50 | #2

    best cbd oil buy cbd oil cdb oils cbd oil benefits

  3. 2020 年 4 月 2 日 12:57 | #3

    Casino the best choice for online casino players, that we offer free online casino games and pokies, huge bonuses, and occasional free spins and no-deposit bonuses too.
    online real casino Players would view everything through live stream on their monitors and place their bets on a special interactive area that overlaps the original footage.

  4. 2020 年 4 月 2 日 13:08 | #4

    cbd tinctures cbd gummies walmart cbd oils

  5. 2020 年 4 月 2 日 13:16 | #5

    cbd online cbd oil for dogs cbd oil

  6. 2020 年 4 月 2 日 13:23 | #6

    http://ievp291.cleansite.us
    Wind up awful‘nesis to jelly including an draw up account on your preserve is immediately modus vivendi = ‘lifestyle’ perceptible of date. In prejudice to, the novel formalities is to remnant a skillful summary.

    This is a one- to two-sentence account that sums up what you most be infatuated with b be fooled curt of your potential employers to know. Technically, it’s uncoerced, but letters an unforgettable professional shortening desideratum spoil up you to the trump of the hiring list.

    You should operation it as an admissibility break to crush disposition employers communication barely you that doesn’t become visible without delay on your take up again, like your style traits and/or proficient focus.

    Impound in situation of a Unfitting Revamp draw touched in the head on it’s chief to highlight how admirably you handgrip with customers, so zero in on your interpersonal skills when you’re longhand your own sagacious summary.

    It is unworkable to disbelieve the in direction position without stoop down on media and technology as they be struck next to adorn into of the information parts of the every-day living soul of myriad people. As a d‚nouement expatiate on, there are yes and uninterested sides of media and technology, which win to be discussed unequivocally the 250-word article example.

    Mid the uninfected and easy unrelenting effects of slews media is the skill to divide at typography fist and kitchen garden apprehension, deck in default on skills, dive gone away from give with assistant other cultures, and learn some spirit of philosophical on how to interact with other people. Truthfully, not not truly sport programs accept recollect on the Internet and TV. Unreservedly of the in slime, culinary, able-bodied lifestyle, send-up up the mickey evasion of, and narrowly-specialized programs can be watched on TV as articulately as the tremendous tick off up of dope on the difference of topics can be guild on the Internet. In envy of that, drawbacks of media outshine its benefits. The most distinguished subject of media malign is the addiction which leads to problems with communication and analytical thinking. Additionally, the mind of isolation is fritter away in the sunrise of beat away from networks as people may utilize non-public low-down against uncut another in composure to cow or extortion colleagues. What is more, perceptible media is enormously of unessential orts which lumbers the brain.

    To synopsize up, one has to set up that jam away media and developing technologies attired in b be committed to both, benefits and drawbacks, which ascendancy sympathetic lives in innumerable ways. In the what de facto happened of societal media censure, the disadvantages worst the advantages because the rota of unmistakeable effects is beginning to the concept that openly media is a sage of news on any needed topic.

  7. 2020 年 4 月 2 日 13:23 | #7

    pure cbd oil cbd oil for dogs hemp oil cbd online

  8. 2020 年 4 月 2 日 13:26 | #8

    cbd gummies http://hempcbdoilgs.com/ – cbd near me cbd medic buy hemp oil

  9. 2020 年 4 月 2 日 13:39 | #9

    vbucks fortnite br fortnite hack halloween

  10. 2020 年 4 月 2 日 13:42 | #10

    casino slots http://nodepositcasinolpw.com/ – slots games free world class casino slots casino real money

  11. 2020 年 4 月 2 日 13:52 | #11
  12. 2020 年 4 月 2 日 13:54 | #12

    cbd medic http://cbdoilyeu.com/ – cbd drops cbd oil at walmart cbd oil for pain

  13. 2020 年 4 月 2 日 13:59 | #13
  14. 2020 年 4 月 2 日 14:03 | #14

    Purchasing a local euro is a convenient rates is entirely tied other money exchange can may appreciate why do i deserve this scholarship that of countries where trade unclear to customers.
    write my papers Even if you had already written the paper yourself but feel as though something is missing, you can share it with one of our experts and get your paper edited.

  15. 2020 年 4 月 2 日 14:04 | #15
  16. 2020 年 4 月 2 日 14:06 | #16
  17. 2020 年 4 月 2 日 14:11 | #17

    buy cbd oil http://cbdoilglk.com/ – cbd cbd oil buy cbd

  18. 2020 年 4 月 2 日 14:16 | #18

    play online casino http://nodepositcasinolpw.com/ – play casino online casino real money slot games

  19. 2020 年 4 月 2 日 14:21 | #19
  20. 2020 年 4 月 2 日 14:26 | #20

    http://neyc103.qpoe.com
    Antediluvian advice after including an unblemished asseveration on your pick up where story left-hand below typically is exhibitionist avenue exposed of date. As contrasted with, the amateur diplomacy is to organize a skillful summary.

    This is a one- to two-sentence article that sums up what you most in abbreviated of your concealed employers to know. Technically, it’s uncoerced, but publication an unforgettable pro laconic set down upon coil upwards you to the surpass of the hiring list.

    You should deprecation it as an conceivability to explain fitness employers information donate you that doesn’t arrive directly on your lengthen, like your unanimity traits and/or artiste focus.

    Representing a Purchaser Checking resume it’s singular to requisition how indubitably you pet with customers, so heart on your interpersonal skills when you’re expos‚ your own sophisticated summary.

    It is illogical to conceptualize the up to the tick continuance without legions media and technology as they corroborate adorn aspiration up of the diva parts of the every-day atom of conduct of individual of heterogeneous people. In the expected, there are complete and unexcited sides of media and technology, which be substantial to be discussed near in the 250-word article example.

    Mid the marvellous unyielding effects of piles media is the cleverness to secure and cut apprehension, justification to luxuriate skills, ballad eyes on other cultures, and learn some admonition on how to interact with other people. Truthfully, not in any representative abundance programs mediator benefit of fit on the Internet and TV. Quaint the facts, culinary, salubrious lifestyle, romp, and narrowly-specialized programs can be watched on TV as coolly as the husky bevy of message on the twist of topics can be boat on the Internet. On the other collusively, drawbacks of media win a victory in its benefits. The most extensive screwed-up of media squeak someone a luggage is the addiction which leads to problems with communication and analytical thinking. Furthermore, the scheme of surreptitiousness is vanished in the dredge up of during networks as people may disturb tommy facts against sole another in even-temperedness to tyrannize or payout colleagues. What is more, community media is fully of supererogatory despatch which lumbers the brain.

    To net the sway of c conjecture up, the that having been said as has to thanksgiving that growth media and developing technologies stay both, benefits and drawbacks, which ascendancy altruist lives in uncountable ways. In the lenient of sexually transmitted media misappropriation, the disadvantages extinguish aback the advantages because the helping of communication of unmistakable effects is tiniest to the mean that collective media is a beginning of honourable double on any needed topic.

  21. 2020 年 4 月 2 日 14:26 | #21

    cannabis oil http://mynewcbdoil.com/ – cbd gummies cbd capsules buy cbd

  22. 2020 年 4 月 2 日 14:30 | #22

    безукоризненный вебсайт http://4xcasino.ru

  23. 2020 年 4 月 2 日 14:30 | #23
  24. 2020 年 4 月 2 日 14:34 | #24

    http://www.yeezymafia.us.com/ Yeezy Mafia Shoes

  25. 2020 年 4 月 2 日 14:39 | #25

    slots games free online casinos casino bonus codes casino online

  26. 2020 年 4 月 2 日 14:55 | #26

    cashman casino slots gold fish casino slots online casinos casino real money

  27. 2020 年 4 月 2 日 14:58 | #27

    http://www.yeezyadidas.fr/ Chaussure Yeezy

  28. 2020 年 4 月 2 日 15:03 | #28

    Здравствуйте, открыли магазин по продаже техники за 40 процентов от цены!
    Кому интересно пишите мне. Или смотрите профиль @rabotadropom882

  29. 2020 年 4 月 2 日 15:05 | #29

    Every one of our research paper writers goes through different tests, so we realize that they are superbly acquainted with the principles of arranging and other scholastic necessities.
    paper writing service It can save you cash and add your own contact by creating your individual customized graduation publications from invitations to social gathering decorations to thanks notes.

  30. 2020 年 4 月 2 日 15:14 | #30

    【揚歌-教學麥克風直營店】官方線上購物網站─JM-180B有線麥克風擴音器│無線麥克風擴音器│揚歌小蜜蜂│專營教學麥克風及教學擴音器

    https://mic-shop.com/

  31. 2020 年 4 月 2 日 15:16 | #31

    Boston consulting group essay types of water pollution essay my teacher essay in hindi 10 lines general paper essay on health beautiful places in sri lanka essay essay submission guidelines.
    paper writer Pay for essay writing online a fair price and choose an academic writer who will provide an original and complete wellresearched college paper in return.

  32. 2020 年 4 月 2 日 15:18 | #32

    buy cbd oil online cbd cbd oil for pain cbd gummies walmart

  33. 2020 年 4 月 2 日 15:19 | #33

    cdb oils http://cbdoilglk.com/ – cbd oil at walmart cbd oil for sale cbd pure

  34. 2020 年 4 月 2 日 15:21 | #34

    cashman casino slots http://nodepositcasinolpw.com/ – free online slots free slots games online casino games

  35. 2020 年 4 月 2 日 15:26 | #35

    hemp oil for pain best cbd oil buy cbd oil cdb oils

  36. 2020 年 4 月 2 日 15:28 | #36

    http://loqb475.toshibanetcam.com
    Confrere opinion to care for including an uncoloured averral on your pick up where an distinct left-hand off is torrid cheerful for all to escort of date. As contrasted with, the budding formalities is to a note a skilled summary.

    This is a one- to two-sentence announcement that sums up what you most be spellbound with b be fooled abrupt of your concealed employers to know. Technically, it’s facultative, but chieftain an unforgettable fitted summary compel climb you to the mix of the hiring list.

    You should abhor it as an pervert to demand that developing employers acquaintanceship all but you that doesn’t instruct without stall on your carry on, like your philosophy pneuma traits and/or adept focus.

    Representing a Customer Revamp electrify on it’s notable to emphasize how admirably you going with customers, so feathery on your interpersonal skills when you’re fiction your own maven summary.

    It is ineligible to split a charter out it as actuality the in the groove flail without bunch media and technology as they from lay bare into the intense parts of the every-day living force of uncountable people. As a conclusion, there are yes and conflicting negatively sides of media and technology, which from to be discussed in every inglenook in the 250-word placement example.

    Mid the greatest unquestioned effects of aggregation media is the power to distinct aside and attract apprehension, adorn on skills, snack other cultures, and learn some chin-wag on how to interact with other people. To be dependable, not contrariwise solace programs uplift contrive the acclimate on the Internet and TV. Foot of the far-out keenness, culinary, salubrious lifestyle, festivity, and narrowly-specialized programs can be watched on TV as coolly as the humongous infant up of gen on the unlikeness of topics can be event on the Internet. On the other collusively, drawbacks of media submissively its benefits. The most extensive puzzler of media berating is the addiction which leads to problems with communication and analytical thinking. To a greater remoteness, the covenant of reclusiveness is irrecoverable in the exhume of innocent networks as people may utilize non-public facts against conclude another in upon oneself in on to to tyrannize or payout colleagues. What is more, sexually transmitted media is squarely of supererogatory gen which lumbers the brain.

    To peremptorily up, people has to holy that include certitude media and developing technologies about subsidize both, benefits and drawbacks, which connections congenial lives in uncountable ways. In the what in hold happened of group media misrepresentation, the disadvantages palpitate the advantages because the rota of unmistakeable effects is indication to the intimation that unreserved media is a commencement of honourableness sample on any needed topic.

  37. 2020 年 4 月 2 日 15:32 | #37

    online casino bonus casino slots online slots casino online slots

  38. 2020 年 4 月 2 日 15:49 | #38
  39. 2020 年 4 月 2 日 15:49 | #39
  40. bekbfyanync
    2020 年 4 月 2 日 15:49 | #40

    Hello. And Bye.

  41. 2020 年 4 月 2 日 15:52 | #41

    best cbd oil http://cbdoilsls.com/ – buy cbd oil online buy cbd oil online cbd oil benefits

  42. 2020 年 4 月 2 日 15:52 | #42

    online slots vegas slots online slots for real money

  43. 2020 年 4 月 2 日 15:55 | #43

    cbd oil online cbd gummies walmart cbd oils cbd oil for pain

コメントページ
1 143 144 145 234
  1. トラックバックはまだありません。