반응형
/*******************************************************************************************************************
-- Title : [Cb5.0] OBJECT/ATTRIBUTE META() 정보 및 KEY(ID) 조회
-- Reference : couchbase.com
-- Key word : meta() meta key id 메타 키 아이디 조회 couchbase 카우치베이스 N1QL n1ql object attribute
object_length object_names length is missing use keys
*******************************************************************************************************************/
■ META() 정보
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | -- META 정보 조회(KEY 출력 가능) SELECT meta().* FROM `travel-sample` WHERE type="hotel" LIMIT 1; -- KEY(ID) 조회 -- META().id에서 id는 반드시 소문자여야 함 SELECT META().id as docid, * FROM `travel-sample` LIMIT 10; -- KEY(ID) 조회 SELECT * FROM `travel-sample` USE KEYS ("hotel_10026"); SELECT * FROM `travel-sample` USE KEYS ["hotel_10026", "hotel_16442"]; SELECT * FROM `travel-sample` WHERE META().id = "hotel_10026"; SELECT * FROM `travel-sample` WHERE META().id in ["hotel_10026", "hotel_16442"]; | cs |
■ Attribute 정보
1 2 3 4 5 6 7 8 | SELECT META().id as ID , OBJECT_LENGTH(aa) as ATTRIBTE_COUNT , OBJECT_NAMES(aa) as ATTRIBTE_NAMES , aa.country, length(aa.country) as ATTRIBTE_LENGTH , aa.country is missing as FILED_MISSING_NO , aa.ttt is missing as FILED_MISSING_YES FROM `travel-sample` aa WHERE META().id = "airline_10"; | cs |
o length() : UTF-8 기준으로 영문 1byte, 한글 3byte 계산
반응형