赞
踩
非分区表:
UPDATE DBS
JOIN TBLS
JOIN SDS ON DBS.DB_ID = TBLS.DB_ID
AND TBLS.SD_ID = SDS.SD_ID
SET SDS.LOCATION = REPLACE ( `LOCATION`, '原始路径前缀', '目标路径前缀‘ )
WHERE
DBS.`NAME` = '库名'
AND TBLS.TBL_TYPE = 'MANAGED_TABLE'
AND SDS.LOCATION LIKE ’原始路径前缀%'
分区表:
UPDATE DBS
JOIN TBLS
JOIN SDS ON DBS.DB_ID = TBLS.DB_ID
AND TBLS.SD_ID = SDS.SD_ID
SET SDS.LOCATION = REPLACE ( `LOCATION`, '原始路径前缀', '目标路径前缀‘ )
WHERE
DBS.`NAME` = '库名'
AND TBLS.TBL_TYPE = 'MANAGED_TABLE'
AND SDS.LOCATION LIKE ’原始路径前缀%'
aws s3 sync 原始路径 目标路径
示例:
aws s3 rm s3://bigdata-database-meta-cn-northwest-1-prod/globalbi.db --recursive
aws s3 sync s3://bigdata-analysis-bikpi-cn-northwest-1/prod/global/globalbi s3://bigdata-database-meta-cn-northwest-1-prod/globalbi.db
非分区表:
UPDATE DBS
JOIN TBLS
JOIN `PARTITIONS`
JOIN SDS ON DBS.DB_ID = TBLS.DB_ID
AND TBLS.TBL_ID = `PARTITIONS`.TBL_ID
AND `PARTITIONS`.SD_ID = SDS.SD_ID
SET SDS.LOCATION = REPLACE ( `LOCATION`, 's3://bigdata-analysis-bikpi-cn-northwest-1/prod/global/globalbi', 's3://bigdata-database-meta-cn-northwest-1-prod/globalbi.db' )
WHERE-- DBS.`NAME` = 'debi'
-- AND TBLS.TBL_TYPE = 'MANAGED_TABLE'
-- AND
SDS.LOCATION LIKE 's3://bigdata-analysis-bikpi-cn-northwest-1/prod/global/globalbi%'
SELECT
DBS.`NAME`,
TBLS.`TBL_NAME`,
TBLS.TBL_TYPE,
SDS.LOCATION
FROM
DBS
JOIN TBLS
JOIN SDS ON DBS.DB_ID = TBLS.DB_ID
AND TBLS.SD_ID = SDS.SD_ID
WHERE
DBS.`NAME` = 'globalbi' -- AND TBLS.TBL_TYPE = 'MANAGED_TABLE'
-- AND
-- SDS.LOCATION LIKE 's3://bigdata-analysis-bikpi-cn-northwest-1/prod/global/globalbi%'
ORDER BY
location
分区表:
UPDATE DBS
JOIN TBLS
JOIN `PARTITIONS`
JOIN SDS ON DBS.DB_ID = TBLS.DB_ID
AND TBLS.TBL_ID = `PARTITIONS`.TBL_ID
AND `PARTITIONS`.SD_ID = SDS.SD_ID
SET SDS.LOCATION = REPLACE ( `LOCATION`, 's3://bigdata-analysis-bikpi-cn-northwest-1/prod/global/globalbi', 's3://bigdata-database-meta-cn-northwest-1-prod/globalbi.db' )
WHERE
-- DBS.`NAME` = 'debi'
-- AND TBLS.TBL_TYPE = 'MANAGED_TABLE'
-- AND
SDS.LOCATION LIKE 's3://bigdata-analysis-bikpi-cn-northwest-1/prod/global/globalbi%'
SELECT
DBS.`NAME`,
TBLS.`TBL_NAME`,
TBLS.TBL_TYPE,
`PARTITIONS`.TBL_ID,
`PARTITIONS`.SD_ID,
SDS.LOCATION
FROM
DBS
JOIN TBLS
JOIN `PARTITIONS`
JOIN SDS ON DBS.DB_ID = TBLS.DB_ID
AND TBLS.TBL_ID = `PARTITIONS`.TBL_ID
AND `PARTITIONS`.SD_ID = SDS.SD_ID
WHERE
DBS.`NAME` = 'globalbi' -- AND TBLS.TBL_TYPE = 'MANAGED_TABLE'
AND SDS.LOCATION LIKE 's3://bigdata-analysis-bikpi-cn-northwest-1/prod/global/globalbi%'
ORDER BY
location
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。