Is there a way to create an auto-incrementing Guid Primary Key in an Oracle database?

前端 未结 2 1421
自闭症患者
自闭症患者 2021-01-19 09:26

I mostly work with sql-server (when I do work with databases) and I am trying to learn pl-sql.

Is there any equivalent to sql-server\'s auto-generated Guid as primary key

2条回答
  •  情歌与酒
    2021-01-19 09:28

    You can use SYS_GUID() to generate a GUID, and use it as DEFAULT value of a column:

    CREATE TABLE test_table (
      uid_col RAW(32) DEFAULT SYS_GUID(),
      some_val VARCHAR2(10)
    );
    

    EDIT: See answers to this question for more details.

提交回复
热议问题