select username,decode(username,'aaa','计算机部门','bbb','市场部门','其他') as 部门 from users;
2018-01-10
select username,case when salary<800 then '工资低' when salary>5000 then '工资高' end as 工资水平 from users;
2018-01-10
select username,case username when 'aaa' then '计算机部门' when'bbb' then '市场部门' else '其他部门' end as 部门 from users;
select username,case when usename='aaa' then '计算机部门' when username='bbb' then '市场部门' else '其他部门' end as 部门 from users;
select username,case when usename='aaa' then '计算机部门' when username='bbb' then '市场部门' else '其他部门' end as 部门 from users;
2018-01-10
select * from users order by id desc;
select * from users order by id desc,salary asc;
insert into users values(4,'aaa',1000);
select * from users order by username desc,salary asc;
select * from users order by id desc,salary asc;
insert into users values(4,'aaa',1000);
select * from users order by username desc,salary asc;
2018-01-10
select * from users where salary beteen 800 and 2000;
select * from users where salary not beteen 800 and 2000;
select * from users where username in ('aaa','bbb');
select * from users where username not in ('aaa','bbb');
select * from users where salary not beteen 800 and 2000;
select * from users where username in ('aaa','bbb');
select * from users where username not in ('aaa','bbb');
2018-01-10
select * from users;
select * from users where username like 'a%';
select * from users where username like 'a_';
select * from users where username like '_a%';
select * from users where username like '%a%';
select * from users where username like 'a%';
select * from users where username like 'a_';
select * from users where username like '_a%';
select * from users where username like '%a%';
2018-01-10
select * from users;
select id,username,salary+200 from users;
select * from users;
select username from users where salary>800;
select username from users where salary>800 and salary<>1800.5;
select username form users where salary>800 or salary<>1800.5;
select id,username,salary+200 from users;
select * from users;
select username from users where salary>800;
select username from users where salary>800 and salary<>1800.5;
select username form users where salary>800 or salary<>1800.5;
2018-01-10
select id as 编号,username as 用户名,salary 工资 from users;
select distinct username as 用户名 from users;
select distinct username as 用户名 from users;
2018-01-10
select * from users;
col id heading 编号;
col username heading 用户名;
col salary heading 工资;
select * from users;
select username,salary from users;
col id heading 编号;
col username heading 用户名;
col salary heading 工资;
select * from users;
select username,salary from users;
2018-01-10
col username heading 用户名;
select * from users;
col username format a10;
select * from users;
col salary format 9999.9;
select * from users;
col salary format 999.9;
select * from users;
col salary format $9999.9;
select * from users;
col username clear;
col salary clear;
select * from users;
select * from users;
col username format a10;
select * from users;
col salary format 9999.9;
select * from users;
col salary format 999.9;
select * from users;
col salary format $9999.9;
select * from users;
col username clear;
col salary clear;
select * from users;
2018-01-10
desc salary
select constraint_name,constraint_type,status from user_constraints where table_name='USERINFO_C3';
alter table userinfo_c3 disable constraint ck_salay_new;
select constraint_name,constraint_type,status from user_constraints where table_name='USERINFO_C3';
select constraint_name,constraint_type,status from user_constraints where table_name='USERINFO_C3';
alter table userinfo_c3 disable constraint ck_salay_new;
select constraint_name,constraint_type,status from user_constraints where table_name='USERINFO_C3';
2018-01-09
create table userinfo_c3(id varchar2(10) primary key, username varchar2(20), salary number(5,0));
alter table userinfo_c3 add constraint ck_salary_new check(salary>0);
alter table userinfo_c3 add constraint ck_salary_new check(salary>0);
2018-01-09
create table userinfo_c1(id varchar2(10) primary key,username varchar2(20), salary number(5,0),constraint ck_salary chack(salary>0));
2018-01-09
create table userinfo_c(id varvhar2(10) primary key, username varchar2(20), salary number(5,0) check(salary>0));
insert into userinfo_c values(1,'aa,-50);
insert into userinfo_c values(1,'aa,-50);
2018-01-09