一.数据库关键字
union,unon all(重复也显示)
select into
Constraint 几种约束 (check index)
二.几种函数关键字(因数据库的不同,会不一样)
AVG() //UCASE()转换为大写 //lcase()
mid(column_name,start,len)start起始从1开始 len() round(字段名,保留小数的位数)
now() getdate()
(1) sqlserver数据库
format(列明,格式)
(2) oracle数据库
upper(大写) lower(小写) initcap concat substr(截取) length(长度) replace(替换) round trunc mod
months_between() add_months() next_day() last_day()
to_char() to_number()
nvl(string1,replace_string) decode(value,if1.then1)
三.详细使用(以oracle为例)
1.自增序列
//auto-increment:oracle中,使用sequence
//sequence
CREATE SEQUENCE seq_person
MINVALUE 1 START WITH 1 INCREMENT BY 1 CACHE 10
//在数据库表中使用
INSERT INTO Persons (P_Id,FirstName,LastName) VALUES (seq_person.nextval,'Lars','Monsen')
2.更改表的列名
ALTER TABLE Persons ALTER COLUMN Birthday year
3.根据表名,查找列名
SELECT rownum,t.* FROM user_tab_columns t where t.table_name ='TEST_SCORE';
4.查找并修改数据库用户密码失效时间
SELECT * FROM dba_profiles WHERE profile='DEFAULT' AND resource_name='PASSWORD_LIFE_TIME';
修改: ALTER PROFILE DEFAULT LIMIT PASSWORD_LIFE_TIME UNLIMITED;
5.case when then使用
select case (select count(*) from table1 where __)
when 0 then (select "" from dual)
else (select count(*) from table2 where __)
end from dual;