ODPS 常用命令汇总

1.切换工程:use projectName;

2.查看工程下的所有表:list tables;

3.查看表的分区:ls partitions tableName;

4.查找分区的数据:select *from tableName where partitionName=partitionValue;

5.查看表结构:desc tableName;

6.get_json_object(src,value)  :

 select poiid from tableName 
 where date_version='20160406' 
 and merged_status != 1 
 and update_flag != 'd'
 and get_json_object(columnName,'$.importance.com_city.rank') is null


7.多表连接/子查询

SELECT count(t1.poiid)
FROM (
	SELECT poiid
		, get_json_object(base, '$.name') AS name
		, get_json_object(base, '$.shortname.shortname') AS shortname
		, serialnumber
		, update_flag
		, merged_status
		, date_version
	FROM cms_monitor.tbl_unique
	WHERE get_json_object(base, '$.shortname.shortname') IS NOT NULL
		AND date_version = 20160401
		AND merged_status != 1
		AND update_flag != 'd'
) t1
JOIN (
	SELECT poiid
		, get_json_object(base, '$.name') AS name
		, get_json_object(base, '$.shortname.shortname') AS shortname
		, serialnumber
		, update_flag
		, merged_status
		, date_version
	FROM cms_monitor.tbl_unique
	WHERE get_json_object(base, '$.shortname.shortname') IS NULL
		AND date_version = 20160409
		AND merged_status != 1
		AND update_flag != 'd'
) t2
ON t1.poiid = t2.poiid


你可能感兴趣的:(Database)