同一個資料庫例項,不同使用者下多表建立檢視,Hibernate完成ORM對映,Spring整合,後臺實現
- 1、同一個資料庫例項,同用戶,多表建立檢視
- 2、同一個資料庫例項,不同使用者下,多表建立檢視
- 3、同一個資料庫,不同資料庫例項,多表建立檢視
4、不同型別資料庫,多表建立檢視
1、同一個資料庫例項,同用戶,多表建立檢視
暫缺!!
2、同一個資料庫例項,不同使用者下,多表建立檢視
步驟一、建立例項,建立兩個使用者的sql:
-- 建立例項 : Database Configuration Assistant 建立資料庫 -- 查詢表SYSTEM表空間的資料檔案的物理路徑 -- SELECT FILE_NAME FROM DBA_DATA_FILES WHERE (TABLESPACE_NAME = 'SYSTEM')
第一個使用者:
備註:採用的2張表:
TB_BAS_CKYX
TB_BAS_META_BLOB第二個使用者:
備註:採用的3張表:
TB_BAS_YGYX
TB_BAS_HEADTABLE
TB_BAS_YXZZCP
步驟二、資料庫表設計:
使用者HY_02C下:
1、TB_BAS_CKYX
sql:
-- Create table
create table TB_BAS_CKYX
(
id VARCHAR2(40) not null,
source_data_id NUMBER(38),
image_no VARCHAR2(50),
image_handling_no VARCHAR2(40),
satellite_code VARCHAR2(50),
sensor_code VARCHAR2(50),
image_rr_value NUMBER(38,8),
image_scale_code VARCHAR2(4),
image_bands VARCHAR2(40),
projection_code VARCHAR2(20),
central_meridian NUMBER(38,8),
locator_unit VARCHAR2(10),
zone_code VARCHAR2(10),
zone_no NUMBER(38),
es_code VARCHAR2(10),
es_value NUMBER(38,8),
cloudcover_code NUMBER(38,8),
tl_lon NUMBER(38,8),
tl_lat NUMBER(38,8),
tr_lon NUMBER(38,8),
tr_lat NUMBER(38,8),
br_lon NUMBER(38,8),
br_lat NUMBER(38,8),
bl_lon NUMBER(38,8),
bl_lat NUMBER(38,8),
tl_x NUMBER(38,8),
tl_y NUMBER(38,8),
tr_x NUMBER(38,8),
tr_y NUMBER(38,8),
br_x NUMBER(38,8),
br_y NUMBER(38,8),
bl_x NUMBER(38,8),
bl_y NUMBER(38,8),
product_ar_code VARCHAR2(10),
product_category_code VARCHAR2(20),
product_ownership_unit VARCHAR2(50),
production_unit VARCHAR2(50),
product_grade_code VARCHAR2(4),
product_quality VARCHAR2(4),
product_security_code VARCHAR2(4),
product_format_code VARCHAR2(4),
product_archive_date TIMESTAMP(6),
product_time_phase DATE,
product_size_measure VARCHAR2(4),
product_size NUMBER(38),
product_quality_report VARCHAR2(500),
product_order_no VARCHAR2(40),
product_storage_path VARCHAR2(500),
create_date TIMESTAMP(6),
used_count NUMBER(38),
status VARCHAR2(4),
remarks VARCHAR2(400),
product_file_list BLOB,
envelope LONG,
source_table_name VARCHAR2(100),
cs_code VARCHAR2(10),
data_name VARCHAR2(400),
sjsj DATE
)
tablespace GF_GXFW
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 128K
minextents 1
maxextents unlimited
);
-- Add comments to the columns
comment on column TB_BAS_CKYX.id
is '記錄編號';
comment on column TB_BAS_CKYX.source_data_id
is '源資料ID';
comment on column TB_BAS_CKYX.image_no
is '圖幅號';
comment on column TB_BAS_CKYX.image_handling_no
is '圖處理關聯編號';
comment on column TB_BAS_CKYX.satellite_code
is '衛星類別';
comment on column TB_BAS_CKYX.sensor_code
is '感測器類別';
comment on column TB_BAS_CKYX.image_rr_value
is '影像解析度';
comment on column TB_BAS_CKYX.image_scale_code
is '影像比例尺';
comment on column TB_BAS_CKYX.image_bands
is '影像波段資訊';
comment on column TB_BAS_CKYX.projection_code
is '投影方式';
comment on column TB_BAS_CKYX.central_meridian
is '中央子午線';
comment on column TB_BAS_CKYX.locator_unit
is '座標單位';
comment on column TB_BAS_CKYX.zone_code
is '分帶型別';
comment on column TB_BAS_CKYX.zone_no
is '投影帶號';
comment on column TB_BAS_CKYX.es_code
is '高程基準';
comment on column TB_BAS_CKYX.es_value
is '高程基準值';
comment on column TB_BAS_CKYX.cloudcover_code
is '雲量';
comment on column TB_BAS_CKYX.tl_lon
is '左上經度';
comment on column TB_BAS_CKYX.tl_lat
is '左上緯度';
comment on column TB_BAS_CKYX.tr_lon
is '右上經度';
comment on column TB_BAS_CKYX.tr_lat
is '右上緯度';
comment on column TB_BAS_CKYX.br_lon
is '右下經度';
comment on column TB_BAS_CKYX.br_lat
is '右下緯度';
comment on column TB_BAS_CKYX.bl_lon
is '左下經度';
comment on column TB_BAS_CKYX.bl_lat
is '左下緯度';
comment on column TB_BAS_CKYX.tl_x
is '左上x座標';
comment on column TB_BAS_CKYX.tl_y
is '左上y座標';
comment on column TB_BAS_CKYX.tr_x
is '右上x座標';
comment on column TB_BAS_CKYX.tr_y
is '右上y座標';
comment on column TB_BAS_CKYX.br_x
is '右下x座標';
comment on column TB_BAS_CKYX.br_y
is '右下y座標';
comment on column TB_BAS_CKYX.bl_x
is '左下x座標';
comment on column TB_BAS_CKYX.bl_y
is '左下y座標';
comment on column TB_BAS_CKYX.product_ar_code
is '行政區';
comment on column TB_BAS_CKYX.product_category_code
is '產品分類';
comment on column TB_BAS_CKYX.product_ownership_unit
is '產品所有權單位';
comment on column TB_BAS_CKYX.production_unit
is '產品生產單位';
comment on column TB_BAS_CKYX.product_grade_code
is '產品等級';
comment on column TB_BAS_CKYX.product_quality
is '產品質檢';
comment on column TB_BAS_CKYX.product_security_code
is '產品祕密等級';
comment on column TB_BAS_CKYX.product_format_code
is '產品格式';
comment on column TB_BAS_CKYX.product_archive_date
is '產品歸檔日期';
comment on column TB_BAS_CKYX.product_time_phase
is '產品時相';
comment on column TB_BAS_CKYX.product_size_measure
is '產品大小單位';
comment on column TB_BAS_CKYX.product_size
is '產品大小';
comment on column TB_BAS_CKYX.product_quality_report
is '產品質量報告';
comment on column TB_BAS_CKYX.product_order_no
is '產品任務單編號';
comment on column TB_BAS_CKYX.product_storage_path
is '產品儲存位置';
comment on column TB_BAS_CKYX.create_date
is '記錄建立時間';
comment on column TB_BAS_CKYX.used_count
is '使用次數';
comment on column TB_BAS_CKYX.status
is '記錄狀態';
comment on column TB_BAS_CKYX.remarks
is '備註';
comment on column TB_BAS_CKYX.product_file_list
is '產品檔案清單';
comment on column TB_BAS_CKYX.envelope
is '產品資料時間(2014年5月27日)';
comment on column TB_BAS_CKYX.source_table_name
is '來源表名';
comment on column TB_BAS_CKYX.cs_code
is '座標系(2014年5月27日)';
comment on column TB_BAS_CKYX.data_name
is '產品名稱(2014年5月27日)';
comment on column TB_BAS_CKYX.sjsj
is '資料範圍';
-- Create/Recreate primary, unique and foreign key constraints
alter table TB_BAS_CKYX
add constraint PK_CKYX_ID primary key (ID)
using index
tablespace GF_GXFW
pctfree 10
initrans 2
maxtrans 255
storage
(
initial 64K
minextents 1
maxextents unlimited
);
-- Grant/Revoke object privileges
grant select on TB_BAS_CKYX to DOPD;
2、TB_BAS_META_BLOB
sql:
-- Create table
create table TB_BAS_META_BLOB
(
f_dataid NUMBER not null,
f_metadata BLOB,
f_quickimage1 BLOB,
f_quickimage2 BLOB,
f_quickimage3 BLOB,
f_quickimage4 BLOB,
f_thumimage BLOB,
f_shapeimage BLOB
)
tablespace HY_02C
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 128M
minextents 1
maxextents unlimited
);
-- Create/Recreate indexes
create index INDEX_TB_BAS_META_BLOB_DATAID on TB_BAS_META_BLOB (F_DATAID)
tablespace HY_02C
pctfree 10
initrans 2
maxtrans 255
storage
(
initial 10M
minextents 1
maxextents unlimited
);
使用者DOPD下:
1、TB_BAS_META_YGYX
sql:
-- Create table
create table TB_BAS_META_YGYX
(
dataid NUMBER,
catalogid VARCHAR2(50),
satelliteid VARCHAR2(50),
sensorid VARCHAR2(50),
recstationid VARCHAR2(50),
subscenemode VARCHAR2(100) not null,
imagingmode VARCHAR2(50),
productdate DATE,
productlevel VARCHAR2(100),
pixelspacing NUMBER,
bands VARCHAR2(255),
scenecount NUMBER,
overallquality NUMBER,
resampletechnique VARCHAR2(100),
productorientation VARCHAR2(100),
trackid NUMBER,
satpath NUMBER,
satrow NUMBER,
satpathbias VARCHAR2(100),
satrowbias VARCHAR2(100),
sunelevation NUMBER,
sunazimuthelevation NUMBER not null,
scenedate DATE,
imagingstarttime VARCHAR2(100),
imagingstoptime VARCHAR2(100),
satoffnadir NUMBER,
cloudamount VARCHAR2(100),
wkt VARCHAR2(255),
scenecenterlat NUMBER,
scenecenterlong NUMBER,
dataupperleftlat NUMBER,
dataupperleftlong NUMBER,
dataupperrightlat NUMBER,
dataupperrightlong NUMBER,
datalowerleftlat NUMBER,
datalowerleftlong NUMBER,
datalowerrightlat NUMBER,
datalowerrightlong NUMBER,
productupperleftlat NUMBER,
productupperleftlong NUMBER,
productupperrightlat NUMBER,
productupperrightlong NUMBER,
productlowerleftlat NUMBER,
productlowerleftlong NUMBER,
productlowerrightlat NUMBER,
productlowerrightlong NUMBER,
scenepath NUMBER,
scenerow NUMBER,
f_datatypename VARCHAR2(100),
f_mapprojection NVARCHAR2(50),
id VARCHAR2(40),
cloud_amount NUMBER,
receive_time DATE,
available VARCHAR2(50)
)
tablespace GF_GXFW
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 192M
minextents 1
maxextents unlimited
);
-- Add comments to the columns
comment on column TB_BAS_META_YGYX.dataid
is '資料唯一標識';
comment on column TB_BAS_META_YGYX.catalogid
is '分類編碼';
comment on column TB_BAS_META_YGYX.satelliteid
is '衛星標識 ZY3';
comment on column TB_BAS_META_YGYX.sensorid
is '譜段模式 PAN MS';
comment on column TB_BAS_META_YGYX.recstationid
is '接收站標識 MY HS SY OS';
comment on column TB_BAS_META_YGYX.subscenemode
is '分景模式 N(注:標準景) d(注:雙倍景) t(注:三倍景) s(注: 條帶影像)';
comment on column TB_BAS_META_YGYX.imagingmode
is '成像模式 N F B L R';
comment on column TB_BAS_META_YGYX.productdate
is '生產日期 YYYYMMDDHHMMSS';
comment on column TB_BAS_META_YGYX.productlevel
is '產品級別 SC GEC eGEC GTC DOM';
comment on column TB_BAS_META_YGYX.pixelspacing
is '空間解析度(像元間距) ';
comment on column TB_BAS_META_YGYX.bands
is '波段號列表(以逗號分隔) 波段號以逗號隔開。波段取值範圍:如,CCD:1,2,3,4,5';
comment on column TB_BAS_META_YGYX.scenecount
is '條帶景數 ';
comment on column TB_BAS_META_YGYX.overallquality
is '質量評價結果 取值範圍:0-9';
comment on column TB_BAS_META_YGYX.resampletechnique
is '幾何處理方式';
comment on column TB_BAS_META_YGYX.productorientation
is '輻射處理方式 ';
comment on column TB_BAS_META_YGYX.trackid
is '軌道號';
comment on column TB_BAS_META_YGYX.satpath
is '星下點PATH 1-457';
comment on column TB_BAS_META_YGYX.satrow
is '星下點ROW 1~480';
comment on column TB_BAS_META_YGYX.satpathbias
is '星下點PATH偏離值 A、B、C、D、E(由東向西)';
comment on column TB_BAS_META_YGYX.satrowbias
is '星下點ROW偏離值 1、2、3、4、5(由北向南)';
comment on column TB_BAS_META_YGYX.sunelevation
is '太陽高度角';
comment on column TB_BAS_META_YGYX.sunazimuthelevation
is '太陽方位角';
comment on column TB_BAS_META_YGYX.scenedate
is '景的日期(影象採集日期) YYYYMMDDHHMMSS';
comment on column TB_BAS_META_YGYX.imagingstarttime
is '該景各波段起始採集時間 YYYYMMDDHHMMSS';
comment on column TB_BAS_META_YGYX.imagingstoptime
is '該景各波段結束採集時間 YYYYMMDDHHMMSS';
comment on column TB_BAS_META_YGYX.satoffnadir
is '衛星側擺角度 -90~+90度';
comment on column TB_BAS_META_YGYX.cloudamount
is '雲蓋量 ';
comment on column TB_BAS_META_YGYX.wkt
is '座標系PROJCS["Transverse Mercator",GEOGCS["China2000",DATUM["China2000",SPHEROID["GRS80",6378137,298.257222101],TOWGS84[0, 0, 0,0,0,0,0]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433]],
//UNIT["meters",1],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",75],PARAMETER["scale_factor",1],PARAMETER["false_easting",500000],PARAMETER["false_northing",0]]';
comment on column TB_BAS_META_YGYX.scenecenterlat
is '景中心緯度 -90~+90度';
comment on column TB_BAS_META_YGYX.scenecenterlong
is '景中心經度 -180~+180度';
comment on column TB_BAS_META_YGYX.dataupperleftlat
is '影象左上角緯度 -90~+90度';
comment on column TB_BAS_META_YGYX.dataupperleftlong
is '影象左上角經度 -180~+180度';
comment on column TB_BAS_META_YGYX.dataupperrightlat
is '影象右上角緯度 -90~+90度';
comment on column TB_BAS_META_YGYX.dataupperrightlong
is '影象右上角經度 -180~+180度';
comment on column TB_BAS_META_YGYX.datalowerleftlat
is '影象左下角緯度 -90~+90度';
comment on column TB_BAS_META_YGYX.datalowerleftlong
is '影象左下角經度 -180~+180度';
comment on column TB_BAS_META_YGYX.datalowerrightlat
is '影象右下角緯度 -90~+90度';
comment on column TB_BAS_META_YGYX.datalowerrightlong
is '影象右下角經度 -180~+180度';
comment on column TB_BAS_META_YGYX.productupperleftlat
is '產品左上角緯度 -90~+90度';
comment on column TB_BAS_META_YGYX.productupperleftlong
is '產品左上經度 -180~+180度';
comment on column TB_BAS_META_YGYX.productupperrightlat
is '產品右上角緯度 -90~+90度';
comment on column TB_BAS_META_YGYX.productupperrightlong
is '產品右上角經度 -180~+180度';
comment on column TB_BAS_META_YGYX.productlowerleftlat
is '產品左下角緯度 -90~+90度';
comment on column TB_BAS_META_YGYX.productlowerleftlong
is '產品左下角經度 -180~+180度';
comment on column TB_BAS_META_YGYX.productlowerrightlat
is '產品右下角緯度 -90~+90度';
comment on column TB_BAS_META_YGYX.productlowerrightlong
is '產品右下角經度 -180~+180度';
comment on column TB_BAS_META_YGYX.scenepath
is '星下點PATH 1-457';
comment on column TB_BAS_META_YGYX.scenerow
is '星下點ROW 1~480';
comment on column TB_BAS_META_YGYX.f_datatypename
is '產品型別';
comment on column TB_BAS_META_YGYX.f_mapprojection
is '地圖投影';
comment on column TB_BAS_META_YGYX.id
is 'guid';
comment on column TB_BAS_META_YGYX.cloud_amount
is '判別後雲量';
comment on column TB_BAS_META_YGYX.receive_time
is '接受時間(採集時間都用這個)';
comment on column TB_BAS_META_YGYX.available
is '0 、2 不可用 1 是可用(BOLB)-1 未判定';
-- Create/Recreate indexes
create index INDEX_TB_BAS_META_YGYX_DATAID on TB_BAS_META_YGYX (DATAID)
tablespace GF_GXFW
pctfree 10
initrans 2
maxtrans 255
storage
(
initial 17M
minextents 1
maxextents unlimited
);
2、TB_BAS_HEADTABLE
sql:
-- Create table
create table TB_BAS_HEADTABLE
(
f_dataid NUMBER(10) not null,
f_productname VARCHAR2(255),
f_productid NUMBER(10),
f_productdate DATE,
f_geographicidentifier VARCHAR2(64),
f_dataformatdes VARCHAR2(50),
f_productunit VARCHAR2(255),
f_importuser VARCHAR2(50),
f_importdate DATE,
f_importway VARCHAR2(20),
f_datasource VARCHAR2(255),
f_getdate DATE,
f_datasize NUMBER(10),
f_dataunit VARCHAR2(50),
f_datadesc VARCHAR2(255),
f_keyword VARCHAR2(100),
f_isfile NUMBER(4),
f_location VARCHAR2(255),
f_flag NUMBER(4),
f_hassdelayer NUMBER(4),
f_hastable NUMBER(4),
f_shape MDSYS.SDO_GEOMETRY,
f_catalogcode VARCHAR2(100),
f_filelist VARCHAR2(2000),
f_dirid NUMBER(10),
f_release NUMBER(2),
f_title VARCHAR2(255),
f_ismark NUMBER,
id VARCHAR2(40)
)
tablespace GF_GXFW
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 104M
minextents 1
maxextents unlimited
);
-- Create/Recreate indexes
create index INDEX_HEADTABLEDATA_DATAID on TB_BAS_HEADTABLE (F_DATAID)
tablespace GF_GXFW
pctfree 10
initrans 2
maxtrans 255
storage
(
initial 17M
minextents 1
maxextents unlimited
);
3、TB_BAS_YXZZCP
sql:
-- Create table
create table TB_BAS_YXZZCP
(
id VARCHAR2(40),
source_data_id NUMBER(38),
image_no VARCHAR2(50),
image_handling_no VARCHAR2(40),
satellite_code VARCHAR2(10),
sensor_types VARCHAR2(10),
image_rr_value NUMBER(38,8),
image_color_values VARCHAR2(4),
image_bands NUMBER(38),
image_pixelbits NUMBER(38),
width_pixels NUMBER(38),
height_pixels NUMBER(38),
cs_code VARCHAR2(4),
projection_desc VARCHAR2(500),
resample_method VARCHAR2(4),
tl_lon NUMBER(38,8),
tl_lat NUMBER(38,8),
tr_lon NUMBER(38,8),
tr_lat NUMBER(38,8),
br_lon NUMBER(38,8),
br_lat NUMBER(38,8),
bl_lon NUMBER(38,8),
bl_lat NUMBER(38,8),
tl_x NUMBER(38,8),
tl_y NUMBER(38,8),
tr_x NUMBER(38,8),
tr_y NUMBER(38,8),
br_x NUMBER(38,8),
br_y NUMBER(38,8),
bl_x NUMBER(38,8),
bl_y NUMBER(38,8),
product_ar_code VARCHAR2(10),
product_category_code VARCHAR2(20),
product_ownership_unit VARCHAR2(50),
production_unit VARCHAR2(50),
product_grade_code VARCHAR2(4),
product_quality VARCHAR2(4),
product_security_code VARCHAR2(4),
product_format_code VARCHAR2(4),
product_archive_date TIMESTAMP(6),
production_date TIMESTAMP(6),
product_size_measure VARCHAR2(4),
product_size NUMBER(38),
product_quality_report VARCHAR2(500),
product_order_no VARCHAR2(40),
product_storage_path VARCHAR2(500),
create_date TIMESTAMP(6),
used_count NUMBER(38),
status VARCHAR2(4),
remarks VARCHAR2(400),
product_file_list BLOB,
envelope LONG,
source_table_name VARCHAR2(100),
image_frame_code VARCHAR2(10),
data_name VARCHAR2(400)
)
tablespace HY_02C
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 3M
minextents 1
maxextents unlimited
);
-- Add comments to the columns
comment on column TB_BAS_YXZZCP.id
is '記錄編號';
comment on column TB_BAS_YXZZCP.source_data_id
is '源資料ID';
comment on column TB_BAS_YXZZCP.image_no
is '圖幅號';
comment on column TB_BAS_YXZZCP.image_handling_no
is '圖處理關聯編號';
comment on column TB_BAS_YXZZCP.satellite_code
is '衛星類別';
comment on column TB_BAS_YXZZCP.sensor_types
is '感測器型別';
comment on column TB_BAS_YXZZCP.image_rr_value
is '影像解析度';
comment on column TB_BAS_YXZZCP.image_color_values
is '影像色彩模式';
comment on column TB_BAS_YXZZCP.image_bands
is '影像波段數';
comment on column TB_BAS_YXZZCP.image_pixelbits
is '畫素位數';
comment on column TB_BAS_YXZZCP.width_pixels
is '行畫素數';
comment on column TB_BAS_YXZZCP.height_pixels
is '列畫素數';
comment on column TB_BAS_YXZZCP.cs_code
is '座標系';
comment on column TB_BAS_YXZZCP.projection_desc
is '投影資訊描述';
comment on column TB_BAS_YXZZCP.resample_method
is '重取樣方法';
comment on column TB_BAS_YXZZCP.tl_lon
is '左上經度';
comment on column TB_BAS_YXZZCP.tl_lat
is '左上緯度';
comment on column TB_BAS_YXZZCP.tr_lon
is '右上經度';
comment on column TB_BAS_YXZZCP.tr_lat
is '右上緯度';
comment on column TB_BAS_YXZZCP.br_lon
is '右下經度';
comment on column TB_BAS_YXZZCP.br_lat
is '右下緯度';
comment on column TB_BAS_YXZZCP.bl_lon
is '左下經度';
comment on column TB_BAS_YXZZCP.bl_lat
is '左下緯度';
comment on column TB_BAS_YXZZCP.tl_x
is '左上x座標';
comment on column TB_BAS_YXZZCP.tl_y
is '左上y座標';
comment on column TB_BAS_YXZZCP.tr_x
is '右上x座標';
comment on column TB_BAS_YXZZCP.tr_y
is '右上y座標';
comment on column TB_BAS_YXZZCP.br_x
is '右下x座標';
comment on column TB_BAS_YXZZCP.br_y
is '右下y座標';
comment on column TB_BAS_YXZZCP.bl_x
is '左下x座標';
comment on column TB_BAS_YXZZCP.bl_y
is '左下y座標';
comment on column TB_BAS_YXZZCP.product_ar_code
is '行政區程式碼';
comment on column TB_BAS_YXZZCP.product_category_code
is '產品分類';
comment on column TB_BAS_YXZZCP.product_ownership_unit
is '產品所有權單位';
comment on column TB_BAS_YXZZCP.production_unit
is '產品生產單位';
comment on column TB_BAS_YXZZCP.product_grade_code
is '產品等級';
comment on column TB_BAS_YXZZCP.product_quality
is '產品質檢';
comment on column TB_BAS_YXZZCP.product_security_code
is '產品祕密等級';
comment on column TB_BAS_YXZZCP.product_format_code
is '產品格式';
comment on column TB_BAS_YXZZCP.product_archive_date
is '產品歸檔日期';
comment on column TB_BAS_YXZZCP.production_date
is '產品生產時間';
comment on column TB_BAS_YXZZCP.product_size_measure
is '產品大小單位';
comment on column TB_BAS_YXZZCP.product_size
is '產品大小';
comment on column TB_BAS_YXZZCP.product_quality_report
is '產品質量報告';
comment on column TB_BAS_YXZZCP.product_order_no
is '產品任務單編號';
comment on column TB_BAS_YXZZCP.product_storage_path
is '產品儲存位置';
comment on column TB_BAS_YXZZCP.create_date
is '記錄建立時間';
comment on column TB_BAS_YXZZCP.used_count
is '使用次數';
comment on column TB_BAS_YXZZCP.status
is '記錄狀態';
comment on column TB_BAS_YXZZCP.remarks
is '備註';
comment on column TB_BAS_YXZZCP.product_file_list
is '產品檔案清單';
comment on column TB_BAS_YXZZCP.envelope
is '產品名稱';
comment on column TB_BAS_YXZZCP.source_table_name
is '來源表名';
comment on column TB_BAS_YXZZCP.image_frame_code
is '影像分幅類別';
comment on column TB_BAS_YXZZCP.data_name
is '資料範圍';
步驟三、建立檢視:
使用者:HY_02C(表TB_BAS_CKYX與TB_BAS_META_BLOB)
使用者:DOPD(TB_BAS_META_YGYX、TB_BAS_HEADTABLE、TB_BAS_YXZZCP)
在使用者DOPD中建立檢視:
1、首先得給DOPD授予HY_02C使用者下表的查詢許可權:
PL/SQL登陸HY_02C使用者,給DOPD使用者授權
grant select any table to DOPD;
2、建立檢視
sql:
create or replace view view_same_ins_multi_user
(dataid, satellite, sensor, cloudcover_amount, upper_leftlong, upper_leftlat, upper_rightlong, upper_rightlat, lower_rightlong, lower_rightlat, lower_leftlong, lower_leftlat, receive_date, product_level, datasize, productname, tb_flag)
as
select
DATAID fid,
SATELLITEID,
SENSORID,
CLOUD_AMOUNT,
DATAUPPERLEFTLONG,
DATAUPPERLEFTLAT,
DATAUPPERRIGHTLONG,
DATAUPPERRIGHTLAT,
DATALOWERRIGHTLONG,
DATALOWERRIGHTLAT,
DATALOWERLEFTLONG,
DATALOWERLEFTLAT,
RECEIVE_TIME,
PRODUCTLEVEL,
F_DATASIZE,
F_PRODUCTNAME,
'tb_bas_meta_ygyx' tb_flag
from DOPD.TB_BAS_META_YGYX ygyx,DOPD.TB_BAS_HEADTABLE head
where ygyx.dataid = head.f_dataid and rownum<=1000
union all
select
SOURCE_DATA_ID fid ,
SATELLITE_CODE,
SENSOR_CODE,
CLOUDCOVER_CODE,
TL_LON,
TL_LAT,
TR_LON,
TR_LAT,
BR_LON,
BR_LAT,
BL_LON,
BL_LAT,
SJSJ,
PRODUCT_GRADE_CODE,
PRODUCT_SIZE,
DATA_NAME,
'tb_bas_ckyx' tb_flag
from HY_02C.TB_BAS_CKYX
union all
select
SOURCE_DATA_ID,
SATELLITE_CODE,
SENSOR_TYPES,
0 CLOUDCOVER_AMOUNT,
TL_LON,
TL_LAT,
TR_LON,
TR_LAT,
BR_LON,
BR_LAT,
BL_LON,
BL_LAT,
to_date('','yyyy/MM/dd hh24:mi:ss') RECEIVE_TIME,
'0' PRODUCTLEVEL,
PRODUCT_SIZE,
DATA_NAME,
'tb_bas_yxzzcp' tb_flag
from DOPD.TB_BAS_YXZZCP
order by fid desc;
上面的基礎準備工作完成之後,上程式碼:
公司框架採用SSH
1、用hibernate完成ORM對映
參考資料: 連線
2、spring整合
3、Java後臺程式碼實現及測試結果
1、在hibernate.properties中配置兩個使用者
“ 1、在hibernate.properties中配置兩個使用者”有誤,請忽略!!!!(不刪除是為了追溯歷史版本,同時留個記號以防下次出錯,
PS:如果需要實現:不同資料庫下不同使用者,或者不同資料庫型別下不同使用者才需要在hibernate.properties中配置多個使用者.
1、只需在hibernate.properties中配置一個使用者
PS:以下在applicationContext-Hibernate.xml新增的“資料來源配置”以及“SessionFactory”配置都只需要一個就行!!(如果需要實現:不同資料庫下不同使用者,或者不同資料庫型別下不同使用者才需要新增多個數據源的配置項以及多個SessionFactory配置項)
2、spring整合配置,在applicationContext-Hibernate.xml新增
1)配置資料來源DataSource,新增如下程式碼:
這裡使用的是DBCP連線池。
<!-- 資料來源 -->
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="url">
<value>${jdbc.url}</value>
</property>
<property name="username">
<value>${jdbc.username}</value>
</property>
<property name="password">
<value>${jdbc.password}</value>
</property>
<!-- 資料庫驅動類 -->
<property name="driverClassName">
<value>${jdbc.driverClassName}</value>
</property>
<!-- 連線池的最大資料庫連線數。設為0表示無限制。 -->
<property name="maxActive">
<value>${maxActive}</value>
</property>
<!-- 最大的空閒連線數,這裡取值為30,表示即使沒有資料庫連線時依然可以保持30個空閒的連線,而不被清除,隨時處於待命狀態。設為0表示無限制。-->
<property name="maxIdle">
<value>${maxIdle}</value>
</property>
<!-- 最大建立連線等待時間(毫秒)。如果超過此時間將接到異常。設為-1表示無限制-->
<property name="maxWait">
<