Home > Backend Development > PHP Tutorial > 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
Release: 2023-03-01 15:24:02
Original
3270 people have browsed it

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()

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template