如何检查Tarantool SQL是否已存在表?
答案 0 :(得分:3)
仅使用SQL工具,可以通过以下方式完成:
SELECT EXISTS (select true from "_space" where "name" = 'table_name')
例如:
tarantool> SELECT EXISTS (select true from "_space" where "name" = 'T1')
---
- metadata:
- name: EXISTS (select true from "_space" where "name" = 'T1')
type: boolean
rows:
- [true]
...
tarantool> SELECT EXISTS (select true from "_space" where "name" = 'T')
---
- metadata:
- name: EXISTS (select true from "_space" where "name" = 'T')
type: boolean
rows:
- [false]
...
在Lua模式下:
tarantool> box.space.T1 ~= nil
---
- true
...
tarantool> box.space.T ~= nil
---
- false
...