1. Time

select curdate(), curtime(), month(birthday) from t_t;

select curdate(), curtime(), month(birthday) month from t_t;

2. Char

i. char_length
select userName, char_length(userName) from t_t;

ii. upper, lower
select userName, char_length(userName), upper(userName), lower(userName) from t_t;

3. Match Function

i. abs
select num, abs(num) from t_t;

ii. sqrt
select num, abs(num), sqrt(num) from t_t;

iii. mod
select num, abs(num), sqrt(num), mod(9,2) from t_t;

4. Cryptographic function

i. password
insert into t_t values(null, '2015-04-08', 'Aa', 1, password('123456'));

ii. md5
insert into t_t values(null, '2015-04-08', 'Aa', 1, md5('123456'));

iii. encode & decode

insert into t_t values(null, '2015-04-08', 'Aa', 1, md5('123456'), encode('abcd','aa'));

select pp, decode(pp,'aa') from t_t where id=7;

SQL操作与数据库特性详解
本文深入探讨了SQL中常用的时间函数、字符处理函数、数学运算函数、加密函数及其应用,通过实例展示了如何使用这些函数进行数据库操作。此外,文章还介绍了如何在数据库中插入数据并使用密码、MD5、编码等安全功能。最后,提供了详细的关键词和新标签,帮助读者快速定位和理解相关技术。
1023

被折叠的 条评论
为什么被折叠?



