zoukankan      html  css  js  c++  java
  • 3.15SQL

    MySQL 添加列,修改列,删除列 ALTER TABLE:添加,修改,删除表的列,约束等表的定义。

    查看列:desc 表名;

    修改表名:alter table t_book rename to bbb;

    添加列:alter table 表名 add column 列名 varchar(30);

    删除列:alter table 表名 drop column 列名;

    修改列名MySQL: alter table bbb change nnnnn hh int;

    修改列名SQLServer:exec sp_rename't_student.name','nn','column';

    修改列名Oracle:lter table bbb rename column nnnnn to hh int;

    修改列属性:alter table t_book modify name varchar(22);

    1、增加月DATE_ADD(cptime,INTERVAL 1 month) 

    create table ahtest1
    SELECT uid, modification,
    DATE_ADD(cptime,INTERVAL 1 month) from ahtest;

    2、DESC 表名称:查询所有名称的数据类型

    3、截取时间的一段

    mysql> select DATE_FORMAT('1997-10-04 22:23:00''%W %M %Y');
    -> 'Saturday October 1997'
    4.right join

    create table uniontable
    select ahtest.uid, ahtest.modification, ahtest.truetime, ahtest.finaltime,
    billtest.debt,billtest.late_fee,billtest.paid_up,billtest.repayment_month
    from ahtest
    right outer join billtest
    on ahtest.finaltime=billtest.repayment_month;

     5.增加,删除列名,增加列

    alter table sensor0 drop create_time ;
    alter table sensor0 add apptime datetime;
    update sensor0 set
    createtime=from_unixtime(create_time/1000.0,'%Y-%m-%d %H:%i:%S') where 1;

  • 相关阅读:
    【leetcode】9. Palindrome Number
    【leetcode】7. Reverse Integer
    【Leetcode】6. ZigZag Conversion
    Mysql读写分离
    Windows下为PHP安装redis扩展
    jquery 写的图片左右连续滚动
    PHP中spl_autoload_register函数的用法
    MySQL命令行查询乱码解决方法:
    AJAX 教程
    Mac安装composer爬过的坑
  • 原文地址:https://www.cnblogs.com/jojo123/p/6554715.html
Copyright © 2011-2022 走看看