Mysql数据库主键是uuid如何插入数据 我使用Mysql数据库,主键是string类型,使用的主键生成策略是uuid,怎样通过sql语句插入数据? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 直接INSERT就行了啊? 你的问题是什么?你用INSERT插入数据的时候有什么地方达不到要求? 直接插入就行了啊。例:mysql> create table t_uuid(id varchar(36) not null primary key, col2 varchar(32));Query OK, 0 rows affected (0.06 sec)mysql> insert into t_uuid values(uuid(), 'row 1');Query OK, 1 row affected (0.03 sec)mysql> insert into t_uuid values(uuid(), 'row 2');Query OK, 1 row affected (0.00 sec)mysql> insert into t_uuid values(uuid(), 'row 3');Query OK, 1 row affected (0.00 sec)mysql> select * from t_uuid;+--------------------------------------+-------+| id | col2 |+--------------------------------------+-------+| c06f05f2-d776-102d-81b9-7e9984c966a0 | row 1 || c2671f66-d776-102d-81b9-7e9984c966a0 | row 2 || c3915895-d776-102d-81b9-7e9984c966a0 | row 3 |+--------------------------------------+-------+3 rows in set (0.03 sec) 一个表字段的递增如何实现? 为什么只能对mysql写 而不能读? 求一条最快速度的sql语句解决方案 mysql客户端连接失败 新手问个多表查询问题.高手在哪? 新手求助:如何删除unique约束 我在MYSQL下误删了数据,我要怎样才能恢复过来? mysql查询中使用了临时表 character_set_database 始终为latin1,改不掉。 mysql5.6存储过程中是否能支持GOTO mysql 插入大数据量 中途抛异常 谁做过mysql的ndb cluster,求教关于索引的问题
mysql> create table t_uuid(id varchar(36) not null primary key, col2 varchar(32));
Query OK, 0 rows affected (0.06 sec)mysql> insert into t_uuid values(uuid(), 'row 1');
Query OK, 1 row affected (0.03 sec)mysql> insert into t_uuid values(uuid(), 'row 2');
Query OK, 1 row affected (0.00 sec)mysql> insert into t_uuid values(uuid(), 'row 3');
Query OK, 1 row affected (0.00 sec)mysql> select * from t_uuid;
+--------------------------------------+-------+
| id | col2 |
+--------------------------------------+-------+
| c06f05f2-d776-102d-81b9-7e9984c966a0 | row 1 |
| c2671f66-d776-102d-81b9-7e9984c966a0 | row 2 |
| c3915895-d776-102d-81b9-7e9984c966a0 | row 3 |
+--------------------------------------+-------+
3 rows in set (0.03 sec)