Pgsql Creating an id--PostgreSQL nextval using

Source: Internet
Author: User
Tags postgresql

-- 这里的"test"专指postgre中的表空间(模式),默认的表空间是"public" DROP SEQUENCE if EXISTS "test"."testseq_id_seq"; CREATE SEQUENCE "test"."testseq_id_seq" INCREMENT 1 MINVALUE 1 MAXVALUE 9223372036854775807 START 1 CACHE 1; DROP TABLE if EXISTS "test"."testtable"; CREATE TABLE "test"."testtable" ( "id" int4 DEFAULT nextval(‘testseq_id_seq‘::regclass) NOT NULL, -- 表数据关联SEQUENCE,每次插入取nextval(‘testseq_id_seq‘)<pre name="code" class="sql"><pre name="code" class="sql">nextval(‘testseq_id_seq‘ "create_date" timestamp(6), "age" int4, "name" varchar(100), "grade" float4 ) WITH (OIDS=FALSE) ; ALTER TABLE "test"."testtable" ADD PRIMARY KEY ("id"); -- 插入数据,不需要写主键nextval(‘testseq_id_seq‘); INSERT into "test"."testtable"(name) values(‘111‘); -- 值数据(varchar)用单引号 -- 先创建sequence的第一个数据.. -- SELECT nextval(‘testseq_id_seq‘); </pre><p></p>

Nextval (' chengdu_boundary_id_seq ':: Regclass)

Pgsql Creating an id--PostgreSQL nextval using

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.