我想用1填充SURVEY_TYPE_ID列 我可以这样吗?
SELECT
SURVEY_ID,
SKILL_ID,
1 AS SURVEY_TYPE_ID,
From Table A
答案 0 :(得分:1)
这应该可以正常工作:
SELECT
SURVEY_ID,
SKILL_ID,
1 AS SURVEY_TYPE_ID
From Table A
此外,如果要在列值中填充字符串,只需添加引号即可。
SELECT
SURVEY_ID,
SKILL_ID,
'id_123' AS SURVEY_TYPE_ID
From Table A
答案 1 :(得分:0)
此查询返回带有第三列的结果集,其值是1
:
SELECT SURVEY_ID, SKILL_ID, 1 AS SURVEY_TYPE_ID
FROM Table_A
(这与删除了虚假逗号的查询相同。)
如果要更改表中列的值,则需要UPDATE
:
UPDATE Table_A
SET SURVEY_TYPE_ID = 1;
如果要向表中添加新列,则语法取决于数据库,但通常如下所示:
ALTER Table_A ADD COLUMN SURVEY_TYPE_ID INT DEFAULT 1;