alter 与update的区别
alter 更新的是表的结构(列):
添加一列:
alter table A add( column1 varchar2(20) default 0 not null );
删除一列:
alter table A drop column <列名>
update 更新的是表的数据:
update yao_1_qyqd2 a
set a.本月放号量 = 0
where a.本月放号量 is null
sum() 与count()区别
sum()函数 是用来计算某一列的数据和(列)
count()函数 是用来统计 表中 条数和(行)
to_char,to_date,to_number
to_char 将 数值型或者日期型 转化为 字符型
例 select to_char(sysdate,‘yyyymmdd’) from dual;
to_date 把 string 转换成 date
例 to_date(‘05 Dec 2000’, ‘DD Mon YYYY’)
to_number 把字符型数值转换为 数字型
例 有张表a,建表格时为了方便将id编写成了 varchar2型
数据如下:
id name
1 Y
2 N
3 M
… …
10 B
现在插入一条
11 S
因为更新的原因将顺序排乱了,
你使用 select* from a order by id 就会乱序,因为1,10,11,按字符排序都会排在2,3…前面
而使用 select* from a order by to_number(id);就可以