Replicated table is a special table schema in OceanBase Database. A replicated table can read the latest data changes from any replica and applies to scenarios with low write frequency requirements but high read latency and read load balancing requirements. For more information about replicated tables, see Create a table.
Examples
Execute the following statement to create a replicated table:
obclient [test]> CREATE TABLE TEST.DUP(C1 INT) DUPLICATE_SCOPE = 'cluster';Provide the partitioning key value in the SQL statement to be executed.
obclient [test]> SELECT * FROM TEST.DUP WHERE C1=123\GRun the
EXPLAIN ROUTEstatement to view the routing process in OceanBase Database Proxy (ODP).obclient [test]> EXPLAIN ROUTE SELECT * FROM test.dup WHERE C1=123\GThe following return result shows that ODP performs routing based on the DUP_REPLICA_FIRST routing strategy.
... > ROUTE_POLICY [INFO] Strong read duplicated table. Ignore proxy route policy and session route policy Route Plan ----------------- > SQL_PARSE:{cmd:"COM_QUERY", table:"dup"} > ROUTE_INFO:{route_info_type:"USE_PARTITION_LOCATION_LOOKUP"} > LOCATION_CACHE_LOOKUP:{mode:"oceanbase"} > TABLE_ENTRY_LOOKUP_START:{} > FETCH_TABLE_RELATED_DATA:{table_entry:"not partition table or part info no exists"} > TABLE_ENTRY_LOOKUP_DONE:{table:"dup", table_id:500685, table_type:"USER TABLE", has_dup_replica:true} > ROUTE_POLICY:{replica:"10.10.10.2:50110", idc_type:"SAME_IDC", zone_type:"ReadWrite", role:"FOLLOWER", type:"FULL", is_dup_replica:true, is_partition_server:true, chosen_route_type:"ROUTE_TYPE_DUP_PARTITION_UNMERGE_LOCAL", route_policy:"DUP_REPLICA_FIRST", trans_consistency:"STRONG", session_consistency:"STRONG", proxy_idc_name:"zue"} > CONGESTION_CONTROL:{svr_addr:"10.10.10.2:50110"}