Home  >  Article  >  Backend Development  >  SQL: The primary key of the data table is of varchar type and does not increase automatically. How to insert the primary key when inserting data?

SQL: The primary key of the data table is of varchar type and does not increase automatically. How to insert the primary key when inserting data?

WBOY
WBOYOriginal
2016-12-01 00:25:213201browse

sql: The primary key of the data table is of varchar type and will not increase automatically. How to insert the primary key when inserting data

Reply content:

sql: The primary key of the data table is of varchar type and will not increase automatically. How to insert the primary key when inserting data

Why should the primary key be set to varchar type?
Maybe you have special needs! When inserting data, just like other fields, that’s it!

It means to use UUID, then you can use a program to generate UUID.

Then use uuid as the primary key

UUID as primary key insert

composer require ramsey/uuid

use RamseyUuidUuid;
$uuid1 = Uuid::uuid1();
echo $uuid1->toString()

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn