联合查询的字段名称及排序考点(附加闪回知识点)


create table CUSTOMERS
(
  CUST_ID        NUMBER(5),
  CUST_LAST_NAME VARCHAR2(10),
  COUNTRY_ID     NUMBER(5)
);

insert into CUSTOMERS (CUST_ID, CUST_LAST_NAME, COUNTRY_ID)
values (1, 'jane', 10);
insert into CUSTOMERS (CUST_ID, CUST_LAST_NAME, COUNTRY_ID)
values (2, 'hanmeimei', 20);
insert into CUSTOMERS (CUST_ID, CUST_LAST_NAME, COUNTRY_ID)
values (3, 'lily', 30);
commit;

SELECT * FROM  customers;



SELECT cust_id,cust_last_name "Last Name"
FROM customers
WHERE country_id=10
UNION
SELECT cust_id cust_no,cust_last_name
FROM customers ActualTests
WHERE country_id=30
ORDER BY 2,1;


SELECT cust_id,cust_last_name "Last Name"
FROM customers
WHERE country_id=10
UNION
SELECT cust_id cust_no,cust_last_name
FROM customers ActualTests
WHERE country_id=30
ORDER BY 2,cust_id;


SELECT cust_id,cust_last_name "Last Name"
FROM customers
WHERE country_id=10
UNION
SELECT cust_id cust_no,cust_last_name
FROM customers ActualTests
WHERE country_id=30
ORDER BY "Last Name";

以上三个的结果都是:


SELECT cust_id,cust_last_name "Last Name"
FROM customers
WHERE country_id=10
UNION
SELECT cust_id cust_no,cust_last_name
FROM customers ActualTests
WHERE country_id=30
ORDER BY cust_no;


SELECT cust_id,cust_last_name "Last Name"
FROM customers
WHERE country_id=10
UNION
SELECT cust_id cust_no,cust_last_name
FROM customers ActualTests
WHERE country_id=30

ORDER BY "cust_no";

以上两个的结果都是:




DROP TABLE customers;

SELECT * FROM  customers;



FLASHBACK table customers to before drop;

SELECT * FROM  customers;


alter table customers DISABLE row movement;(系统原本是开启的,我修改成不可用以便进行测试)
UPDATE customers SET cust_last_name='lilei' WHERE cust_id=2;

COMMIT;
flashback table customers to TIMESTAMP systimestamp - interval '2' minute;


SELECT * FROM  customers;


alter table customers enable row movement; (闪回表必须要开启行移动功能!)
UPDATE customers SET cust_last_name='hanmeimei' WHERE cust_id=2;

COMMIT;
flashback table customers to TIMESTAMP systimestamp - interval '1' minute;

SELECT * FROM  customers;




DROP TABLE customers;

select * from user_recyclebin;


FLASHBACK table customers to before drop;
drop table customers purge;
FLASHBACK table customers to before drop;





评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值