我有下面的插入语句
INSERT INTO KeyValue (id, key, value) VALUES (101, 'color', 'green');
INSERT INTO KeyValue (id, key, value) VALUES (102, 'color', 'green');
INSERT INTO KeyValue (id, key, value) VALUES (103, 'color', 'green');
有没有办法对齐列名和值,以便于读取值(值在列名下面)?
像
INSERT INTO KeyValue (id, key, value)
VALUES (101, 'color', 'green');
INSERT INTO KeyValue (id, key, value)
VALUES (102, 'color', 'green');
INSERT INTO KeyValue (id, key, value)
VALUES (103, 'color', 'green');
有这个工具吗?好的,任何SQL,shell,python,正则表达式技巧。
答案 0 :(得分:0)
我更喜欢使用INSERT INTO SELECT
:
INSERT INTO KeyValue (id, key, value)
SELECT 101 AS id, 'color' AS key, 'green' AS value;
-- FROM dual -- if Oracle
或多线:
INSERT INTO KeyValue(
id
,key
,value
)
SELECT
101 AS id
,'color' AS key
,'green' AS value;
说明: