Sql 查询中列标题中的空格
Sql 查询中列标题中的空格,sql,postgresql,Sql,Postgresql,CREATE TABLE inventory ( id SERIAL PRIMARY KEY, product VARCHAR, quantity DECIMAL ); INSERT INTO inventory (product, quantity) VALUES ('product_01', '800'), ('product_02', '300'), ('product_03', '200'), ('product_04', '500'), ('product_
CREATE TABLE inventory (
id SERIAL PRIMARY KEY,
product VARCHAR,
quantity DECIMAL
);
INSERT INTO inventory
(product, quantity)
VALUES
('product_01', '800'),
('product_02', '300'),
('product_03', '200'),
('product_04', '500'),
('product_05', '600'),
('product_06', '400');
预期结果:
product_name | product name |
--------------|------------------|---------
product_01 | product_01 |
product_02 | product_02 |
product_03 | product_03 |
product_04 | product_04 |
product_05 | product_05 |
product_06 | product_06 |
我的问题是,我无法像在中那样在查询中命名列
product name
据我所知,原因是
postgresql
不接受产品和名称之间的空格
我当前正在使用此查询:
SELECT
iv.product AS product_name,
iv.product AS 'product name'
FROM inventory iv;
在
postgresql
中有没有办法实现这一点,或者是没有空格的唯一选项?使用双引号:
SELECT iv.product AS product_name,
iv.product AS "product name"
FROM inventory iv;