mysql笔记

针对之前工作中用到的mysql基本知识的整理,这里只写一些实例:

(1)alert添加字段:语法:alert table tablename add colummname datatype [default];其中default可选

alter table  TN_APPLICATION add checkCodeyear number(4) default 2017;

(2)

update TN_APPLICATION set checkCodeyear=to_number(to_char(sysdate,'yyyy'))
where checkCode=(select max(maxV)
from (select nvl(max(t1.checkCode), 0) as maxV
from TN_REGISTER_STANDARD t1
where t1.year = 2018
union
select nvl(max(t2.checkCode), 0) as maxV
from TN_VARIETY_CHECK t2
where t2.year = 2018
union
select nvl(max(t3.checkCode), 0) as maxV
from TN_APPLICATION t3
where t3.year = 2018));

原文地址:https://www.cnblogs.com/lojun/p/9043366.html