Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/postgresql/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql 查询中列标题中的空格_Sql_Postgresql - Fatal编程技术网

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;