Add a field to a default value

(1) to a database field plus a default value

ALTER COLUMN ALTER TABLE table name field name SET DEFAULT 'https://image.baidu.com/search/my.jpg';

ALTER TABLE mc.banner ALTER COLUMN banner_pic SET DEFAULT '[{"index":"0","url":"http://www.baidu"},{"index":"1","url":"http://www.baidu"}]';

 

(2) pg database implementation id increment

Data tables are created to give the serial number, and serial number can be configured to pick up in xml

a. Create a sequence number (public schematically and in double quotes)

CREATE SEQUENCE “public”.“table_user_user_id_seq”
INCREMENT 1
START 1
MINVALUE 1
CACHE 1;

b. Take sequence number in xml

<selectKey keyProperty="id" order="BEFORE" resultType="java.lang.Long">
select nextval('banner_id_seq')
</selectKey>

 

Guess you like

Origin www.cnblogs.com/wth21-1314/p/11417934.html