1.更改类型(设置为主键的列不能更改类型)
ALTER TABLE "SCHEMA"."TABLENAME" ALTER COLUMN "COL" SET DATA TYPE VARCHAR(32);
ALTER TABLE "SCHEMA"."TABLENAME" ALTER COLUMN "COL" SET DEFAULT 'ABC';
ALTER TABLE "SCHEMA"."TABLENAME" ALTER COLUMN "COL" SET DEFAULT; --设置默认值
ALTER TABLE "SCHEMA"."TABLENAME" ALTER COLUMN "COL" DROP DEFAULT; --删除默认
值
ALTER TABLE "SCHEMA"."TABLENAME" ALTER COLUMN "COL" SET NOT NULL;
ALTER TABLE "SCHEMA"."TABLENAME" ALTER COLUMN "COL" DROP NOT NULL;
更改列类型,是否允许空值后,需要执行REORG TABLE “TABLENAME”;
更改默认值后,通常需要执行
UPDATE "SCHEMA"."TABLENAME" SET "COL" = DEFAULT WHERE "COL" IS NULL;
SELECT MANUFACTORY_ID as "manuFactoryId",
DEVICE_ID as "deviceId",
DEVICE_NAME as "deviceName",
SUM(QTYD_01) as "qtyd01",
SUM(QTYD_02) as "qtyd02",
group by MANUFACTORY_ID,DEVICE_ID,DEVICE_NAME;
官网
decimal(SUM(QTYD_01),2) as "qtyd01",
-- 查看版本
SELECT service_level, fixpack_num FROM TABLE(sysproc.env_get_inst_info()) as INSTANCEINFO
CASE WHEN QTYD_01 = 0 THEN 1 END
-- START_DATE = YYYYMMDDHH24
to_date(START_DATE, 'YYYY-MM-DD HH24')
TIMESTAMP_FORMAT(START_DATE, 'YYYYMMDDHH24')
-- 日期格式可以直接加减日期值
START_DATE + 1 DAY - HOUR(START_DATE) HOURS
DATE (START_DATE) as START_DATE,
-- 2023-11-01 00:00:00.000000 转为2023-11-01
也可以添加
PACKING_TYPE || '_' ||PACKING_SPECIFICATION as "packageType"
SELECT CONCAT(field1, ' ', field2) as combinedField
FROM yourTable;
-- 上个月最后一天
SELECT TO_CHAR(LAST_DAY(TIMESTAMP_FORMAT('202401','YYYYMM') - 1 MONTHS),'yyyyMMdd') as a FROM
-- 上个月第一天
SELECT TO_CHAR(LAST_DAY(TIMESTAMP_FORMAT('202401','YYYYMM') - 2 MONTHS)+1 DAY ,'yyyyMMdd') as a FROM
-- 这个月第一天
SELECT TO_CHAR(LAST_DAY(TIMESTAMP_FORMAT('202401','YYYYMM') - 1 MONTHS)+1 DAY ,'yyyyMMdd') as a FROM
-- 这个月最后一天
SELECT TO_CHAR(LAST_DAY(TIMESTAMP_FORMAT('202401','YYYYMM'))-1 DAY ,'yyyyMMdd') as a FROM
个人笔记,不同意见,望有交流
直接可以点击跳转连接
作者: RyanDYJ
个人笔记,不同意见,望有交流
直接可以点击跳转连接
作者