← 返回 openai 的题目列表Implement Basic SQL Features
类型:online_judge
Design a basic in-memory database that supports the following SQL features:
GET and SET: Implement GET and SET statements to store and retrieve string-type data.
WHERE: Implement the WHERE clause to retrieve records that meet specific conditions from a collection.
ORDER BY: Implement the ORDER BY clause to sort results.
Input Description:
A series of SQL statements, each ending with a semicolon (;).
Supported operations include retrieving, setting string-type key-value pairs, and using WHERE and ORDER BY clauses for filtering and sorting.
Output Description:
Return results according to the input SQL queries.
Example:
SET foo bar;
GET foo;
SET baz hello;
GET baz WHERE foo = 'bar';
GET * ORDER BY baz;
Data Scale:
Handle up to 1000 statements.
No more than 1000 key-value pairs.
Implement the interface with the function signature handle_sql(queries: List[str]) -> List[str], where queries is the list of SQL statements, and it returns the corresponding result list.
Example
Input
SET a 10;
GET a;
GET b;