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;

  • 相关阅读:
    AtCoder Grand Contest 015 题解
    AtCoder Grand Contest 014 题解
    AtCoder Grand Contest 013 题解
    AtCoder Grand Contest 012 题解
    AtCoder Grand Contest 011 题解
    AtCoder Grand Contest 010 题解
    AtCoder Grand Contest 009 题解
    NOIP2017 Day2 题解
    博客园主题备份
    多项式全家桶
  • 原文地址:https://www.cnblogs.com/jojo123/p/6554715.html
Copyright © 2011-2022 走看看