2020年4月27日

    1. INSERT INTO users (name,phone)VALUES('QT3,'13245564');
    2. INSERT INTO users (name,phone)VALUES('QT4,'13245565');
    3. INSERT INTO users VALUES(0,'QT5,'13245566','123456');
    4. INSERT INTO users (name,phone)
    5. VALUES
    6. ('QT6','13245567'),
    7. ('QT7','13245568')
    8. ;
    9. INSERT INTO users
    10. VALUES
    11. (0,'QT8','13245569,'123456'),
    12. (0,'QT9','132455610,'123456')
    13. ;
    14. INSERT INTO birds_body_shapes(body_id, body_shape)
    15. VALUES
    16. ('HMD','Hummingbird'),
    17. ('LLW','Long-Legged wader'),
    18. ('MHH','Marsh Hen'),
    19. ('PHB','Perching Bird'),
    20. ('PWB','Perching Water Bird')
    21. ;
    22. INSERT INTO birds_wing_shapes(wing_id,wing_shape)
    23. VALUES
    24. ('HMD','Broad'),
    25. ('LLW','Rounded'),
    26. ('MHH','Pointed'),
    27. ('PHB','Long'),
    28. ('PWB','Very Long')
    29. ;
    30. INSERT INTO users (name,phone)VALUES('QT3,'13245564');
    31. INSERT INTO users (name,phone)VALUES('QT4,'13245565');
    32. INSERT INTO users VALUES(0,'QT5,'13245566','123456');
    33. INSERT INTO users (name,phone)
    34. VALUES
    35. ('QT6','13245567'),
    36. ('QT7','13245568')
    37. ;
    38. INSERT INTO users
    39. VALUES
    40. (0,'QT8','13245569,'123456'),
    41. (0,'QT9','132455610,'123456')
    42. ;
    43. INSERT INTO birds_body_shapes(body_id, body_shape)
    44. VALUES
    45. ('HMD','Hummingbird'),
    46. ('LLW','Long-Legged wader'),
    47. ('MHH','Marsh Hen'),
    48. ('PHB','Perching Bird'),
    49. ('PWB','Perching Water Bird')
    50. ;
    51. INSERT INTO birds_wing_shapes(wing_id,wing_shape)
    52. VALUES
    53. ('HMD','Broad'),
    54. ('LLW','Rounded'),
    55. ('MHH','Pointed'),
    56. ('PHB','Long'),
    57. ('PWB','Very Long')
    58. ;
    59. INSERT INTO users (name,phone)VALUES('QT3,'13245564');
    60. INSERT INTO users (name,phone)VALUES('QT4,'13245565');
    61. INSERT INTO users VALUES(0,'QT5,'13245566','123456');
    62. INSERT INTO users (name,phone)
    63. VALUES
    64. ('QT6','13245567'),
    65. ('QT7','13245568')
    66. ;
    67. INSERT INTO users
    68. VALUES
    69. (0,'QT8','13245569,'123456'),
    70. (0,'QT9','132455610,'123456')
    71. ;
    72. INSERT INTO birds_body_shapes(body_id, body_shape)
    73. VALUES
    74. ('HMD','Hummingbird'),
    75. ('LLW','Long-Legged wader'),
    76. ('MHH','Marsh Hen'),
    77. ('PHB','Perching Bird'),
    78. ('PWB','Perching Water Bird')
    79. ;
    80. INSERT INTO birds_wing_shapes(wing_id,wing_shape)
    81. VALUES
    82. ('HMD','Broad'),
    83. ('LLW','Rounded'),
    84. ('MHH','Pointed'),
    85. ('PHB','Long'),
    86. ('PWB','Very Long')
    87. ;

    笔记:
    插入数据语法:
    INSERT INTO 表名[(字段1,字段2…)] VALUES(value…) [,(value…),…];
    插入单挑数据的基本方式:数据的基本单位都是按行来提示
    插入特点的字段:可以插入部分字段数据来添加一行,字段可以设置默认值,如果没有被插入则使用默认值;
    例如:INSERT INTO users(name,phone)VALUES(‘QT5’,’13245566’);
    NOT NULL指的是值不能为null,设置之后默认值还是null,那字段就必须被插入
    插入所有字段:
    INSERT INTO users VALUES(0,’QT6,’123456’);
    DEFAULT:直接使用数据库里的默认值
    一次插入多条数据
    指定字段

    INSERT INTO users (name,phone)
    VALUES
    (‘QT6’,’13245567’),
    (‘QT7’,’13245568’),
    …;
    所有字段
    INSERT INTO users
    VALUES
    (0,’QT8’,’13245569,’123456’),
    (0,’QT9’,’132455610,’123456’),
    …;
    明确插入:一次只能插入一条数据
    INSERT INTO 表名 SET 字段名1=值1[,字段名2=值2 …];
    INSERT INTO users SET name=’QT10’,phone=’132455611’;

    替换重复数据(擦汗如数据操作)

    支持多条数据插入
    在唯一键的字段下遇到重复值,则会删除数据表内原有的一行数据,再将新数据插入
    REPLACE INTO users(name,phone) VALUES(‘QT11’,’132455611’);