• mysql你确定掌握的那些sql语句


    1.创建表

    create table test(uid int not null,create_time timestamp default current_timestamp);

    即:没有双引号,单引号啥的,累不累。只要保证字段之间是逗号分隔。

    2.插入表

    insert into test(uid,create_time)values(2111,3147937);

    即:插入的时候要在表的小括号里面指定要插入的字段名,然乎values记住是values里面写对应的值,总之字段之间都是逗号分隔。

    insert into 的时候就不需要些table了,直接写表名就可以。因为insert into肯定是直接插入表了。数据库知道肯定是插入表的操作了。不需要再明确指出了。

    不像create的时候,必须要指出create table,因为你也可能create的是database

    3.更改表

    alter table test change 旧字段名 新字段名 类型属性

    4.字段类型设置为timestamp时注意事项

    :设置timestamp的默认值为当前时间,设置字段default 值为current_timestamp系统变量,表示为当前时间。如果设置每次更改记录时候,timestamp自动更新时间,

    则设置default current_timestamp on update current_timestamp;

    最终命令alter table test56578 change timesss timesss not null default current_timestamp on update current_timestamp;

    5.mysql update修改记录操作,修改记录,是记录!update修改的是记录!!!

    UPDATE persondata SET age=age*2, age=age+1 where ***;

    update

    6.

    1. alter table `user_movement_log`   
    2. Add column GatewayId int not null default 0 AFTER `Regionid` (在哪个字段后面添加)  
    3.  

    删除字段:

    1. alter table `user_movement_log` drop column Gatewayid  

    7.设置字段默认值 default

    8.update语句不需要加table表名。直接update user set age = age +5 where uid =1000

  • 相关阅读:
    Programming Contest Ranking(题解)
    Alphabet Cookies
    hpu 1267 Cafeteria (01背包)
    Triangles 正多边形分割锐角三角形
    ACdream 1067:Triangles
    hdu 1253 胜利大逃亡 (代码详解)解题报告
    最短路
    POJ- 1511 Invitation Cards
    E
    HDU
  • 原文地址:https://www.cnblogs.com/panxuejun/p/6136414.html
Copyright © 2020-2023  润新知