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;

  • 相关阅读:
    编写 iPhone Friendly 的 Web 应用程序
    WebService的安全性讨论【身份识别】
    使用InstallShield系统变量的缺省值
    数据库用户操作相关
    TFS2010安装
    微软实验虚拟机下载地址
    生成18位不重复的ID
    Linux 账户 帐户管理 文件权限 权限管理
    Chrome 插件开发
    Ubuntu 环境变量 设置
  • 原文地址:https://www.cnblogs.com/jojo123/p/6554715.html
Copyright © 2011-2022 走看看