面试题答案
一键面试- 创建UDT(用户自定义类型)
CREATE TYPE hobby_type ( hobby_name text, hobby_description text, hobby_tags list<text> );
- 创建表
CREATE TABLE users ( user_id uuid PRIMARY KEY, user_name text, hobbies set<hobby_type> );
- 插入数据
INSERT INTO users (user_id, user_name, hobbies) VALUES ( uuid(), 'John Doe', { { 'hobby_name': 'Reading', 'hobby_description': 'Love to read books of various genres', 'hobby_tags': ['fiction', 'non - fiction', 'classics'] }, { 'hobby_name': 'Traveling', 'hobby_description': 'Explore new places around the world', 'hobby_tags': ['adventure', 'culture', 'nature'] } } );