Oracle-Join
Posted hongwei2085
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Oracle-Join相关的知识,希望对你有一定的参考价值。
1、建表语句
CREATE TABLE Websites(
ID INT PRIMARY KEY,
NAME VARCHAR2(30),
URL VARCHAR2(100),
alexa INT,
country VARCHAR2(30)
);
INSERT INTO Websites(ID,NAME,URL,alexa,country)VALUES(1,‘Google‘,‘http://www.google.com/‘,1,‘USA‘);
INSERT INTO Websites(ID,NAME,URL,alexa,country)VALUES(2,‘淘宝‘,‘http://www.taobao.com/‘,13,‘CN‘);
INSERT INTO Websites(ID,NAME,URL,alexa,country)VALUES(3,‘天猫‘,‘http://www.tianmao.com/‘,16,‘CN‘);
INSERT INTO Websites(ID,NAME,URL,alexa,country)VALUES(4,‘微博‘,‘http://www.weibo.com/‘,20,‘CN‘);
INSERT INTO Websites(ID,NAME,URL,alexa,country)VALUES(5,‘Facebook‘,‘http://www.facebook.com/‘,3,‘USA‘);
INSERT INTO Websites(ID,NAME,URL,alexa,country)VALUES(7,‘stackoverflow‘,‘http://www.stackoverflow.com/‘,0,‘IND‘);
CREATE TABLE access_log(
aid INT PRIMARY KEY,
site_id INT,
COUNT INT,
datetime date
);
INSERT INTO access_log(aid,site_id,COUNT,datetime)VALUES(1,1,45,to_timestamp(to_char(systimestamp,‘YYYY-MM-DD HH24:MI:SS.FF‘),‘YYYY-MM-DD HH24:MI:SS.FF‘));
INSERT INTO access_log(aid,site_id,COUNT,datetime)VALUES(2,3,100,to_timestamp(to_char(systimestamp,‘YYYY-MM-DD HH24:MI:SS.FF‘),‘YYYY-MM-DD HH24:MI:SS.FF‘));
INSERT INTO access_log(aid,site_id,COUNT,datetime)VALUES(3,1,230,to_timestamp(to_char(systimestamp,‘YYYY-MM-DD HH24:MI:SS.FF‘),‘YYYY-MM-DD HH24:MI:SS.FF‘));
INSERT INTO access_log(aid,site_id,COUNT,datetime)VALUES(4,2,10,to_timestamp(to_char(systimestamp,‘YYYY-MM-DD HH24:MI:SS.FF‘),‘YYYY-MM-DD HH24:MI:SS.FF‘));
INSERT INTO access_log(aid,site_id,COUNT,datetime)VALUES(5,5,205,to_timestamp(to_char(systimestamp,‘YYYY-MM-DD HH24:MI:SS.FF‘),‘YYYY-MM-DD HH24:MI:SS.FF‘));
INSERT INTO access_log(aid,site_id,COUNT,datetime)VALUES(6,4,13,to_timestamp(to_char(systimestamp,‘YYYY-MM-DD HH24:MI:SS.FF‘),‘YYYY-MM-DD HH24:MI:SS.FF‘));
INSERT INTO access_log(aid,site_id,COUNT,datetime)VALUES(7,3,220,to_timestamp(to_char(systimestamp,‘YYYY-MM-DD HH24:MI:SS.FF‘),‘YYYY-MM-DD HH24:MI:SS.FF‘));
INSERT INTO access_log(aid,site_id,COUNT,datetime)VALUES(8,5,545,to_timestamp(to_char(systimestamp,‘YYYY-MM-DD HH24:MI:SS.FF‘),‘YYYY-MM-DD HH24:MI:SS.FF‘));
INSERT INTO access_log(aid,site_id,COUNT,datetime)VALUES(9,3,201,to_timestamp(to_char(systimestamp,‘YYYY-MM-DD HH24:MI:SS.FF‘),‘YYYY-MM-DD HH24:MI:SS.FF‘));
SELECT * FROM Websites;
SELECT * FROM access_log;
2、
以上是关于Oracle-Join的主要内容,如果未能解决你的问题,请参考以下文章