创建多租户表:
CREATE TABLE base.event (tenant_id VARCHAR, event_type CHAR(1), created_date DATE, event_id BIGINT) MULTI_TENANT=true;
连接到某租户的数据库表:
Properties props = new Properties(); props.setProperty("TenantId", "Acme"); Connection conn = DriverManager.getConnection("localhost", props);
在特定租户连接的情况下,以下语句只创建特定租户的视图
CREATE VIEW acme.event AS SELECT * FROM base.event;
CREATE VIEW acme.login_event AS SELECT * FROM base.event WHERE event_type='L';