您的位置:首页 > 数据库

sql基础常用函数总结

2016-05-16 23:50 477 查看
--查表,*可以替换为table列的名称,select是对table的筛选,*代表所有列
select * from table
--更新UPDATE 表名称 SET 列名称 = 新值 WHERE 列名称 = 某值
update table set username='jack'
--删除
delete from table
--删除一列
delete from table where username is null
--字符串处理
lower()--转化小写
select lower(username) from table
intcap--首字母大写
select initcap(username) from table
--截取
select substr(username,开始(int),结束(int)) from table
--判断字符串的位置
select instr('被搜索的字符串','希望搜索到的字符串') from table
--字符串替换,
select replace(列名,'需替换字段','替换字段') from table
--数字处理
--数字四舍五入
select round(列) from table
--小数截断
select trunc(列,截断几位) from table
--取余
select mod(列,取余第几位) from table

--日期转化
--to_date()yyyy-mm-dd hh24:mi:ss日期格式根据需求的修改
select to_date('2016-05-16 18:22:22','yyyy-mm-dd hh24:mi:ss') from table




--字符串处理函数 to_char(),to_numbe()r,to_date()




--to_char用法如图


内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  函数 sql select