2个回答
2020-09-08 · MySQL开源数据库领先者
关注
展开全部
VALUES 语句
具体语法:VALUES row_constructor_list[ORDER BY column_designator][LIMIT BY number] row_constructor_list: ROW(value_list)[, ROW(value_list)][, ...]value_list: value[, value][, ...]column_designator: column_index
VALUES 语句,用做功能展示或者快速造数据场景,结果列名字以 COLUMN_0 开头,以此类推,举个简单例子。单条 VALUES 语句mysql-(ytt/3305)->values row(1,2,3);+----------+----------+----------+| column_0 | column_1 | column_2 |+----------+----------+----------+| 1| 2| 3|+----------+----------+----------+1 row inset(0.00 sec)
多条 VALUES 语句mysql-(ytt/3305)->values row(1,2,3),row(10,9,8);+----------+----------+----------+| column_0 | column_1 | column_2 |+----------+----------+----------+| 1 | 2 | 3 || 10 | 9 | 8 |+----------+----------+----------+2 rows in set (0.00 sec)
多条 VALUES 联合 UNION ALLmysql-(ytt/3305)->values row(1,2,3),row(10,9,8) union all values \ row(-1,-2,0),row(10,29,30),row(100,20,-9);+----------+----------+----------+| column_0 | column_1 | column_2 |+----------+----------+----------+| 1 | 2 | 3 || 10 | 9 | 8 || -1 | -2 | 0 || 10 | 29 | 30 || 100 | 20 | -9 |+----------+----------+----------+5 rows in set (0.00 sec)
根据字段下标排序,从 1 开始mysql-(ytt/3305)->values row(1,2,3),row(10,9,8) union all values \ row(-1,-2,0),row(10,29,30),row(100,20,-9) order by 1 desc ;+----------+----------+----------+| column_0 | column_1 | column_2 |+----------+----------+----------+| 100 | 20 | -9 || 10 | 9 | 8 || 10 | 29 | 30 || 1 | 2 | 3 || -1 | -2 | 0 |+----------+----------+----------+5 rows in set (0.00 sec)
类型可以任意组合:bit,json,datetime,int,decimal 等mysql-(ytt/3305)->values row(100,200,300),\ row('2020-03-10 12:14:15','mysql','test'), \ row(16.22,TRUE,b'1'), \ row(left(uuid(),8),'{"name":"lucy","age":"28"}',hex('dble'));+---------------------+----------------------------+--------------------+| column_0 | column_1 | column_2 |+---------------------+----------------------------+--------------------+| 100 | 200 | 0x333030 || 2020-03-10 12:14:15 | mysql | 0x74657374 || 16.22 | 1 | 0x01 || c86fd1a7 | {"name":"lucy","age":"28"} | 0x3634363236433635 |+---------------------+----------------------------+--------------------+4 rows in set (0.00 sec)
新建表 t3,把刚才这些记录写进去mysql-(ytt/3305)->create table t3 (r1 varchar(100),r2 varchar(100),r3 varchar(100));Query OK, 0 rows affected (0.02 sec)
写入到表 t3mysql-(ytt/3305)->insert into t3 values row(100,200,300), \ row('2020-03-10 12:14:15','mysql','test'), \ row(16.22,TRUE,b'1'),\ row(left(uuid(),8),'{"name":"lucy","age":"28"}',hex('dble'));Query OK, 4 rows affected (0.00 sec)Records: 4 Duplicates: 0 Warnings: 0
具体语法:VALUES row_constructor_list[ORDER BY column_designator][LIMIT BY number] row_constructor_list: ROW(value_list)[, ROW(value_list)][, ...]value_list: value[, value][, ...]column_designator: column_index
VALUES 语句,用做功能展示或者快速造数据场景,结果列名字以 COLUMN_0 开头,以此类推,举个简单例子。单条 VALUES 语句mysql-(ytt/3305)->values row(1,2,3);+----------+----------+----------+| column_0 | column_1 | column_2 |+----------+----------+----------+| 1| 2| 3|+----------+----------+----------+1 row inset(0.00 sec)
多条 VALUES 语句mysql-(ytt/3305)->values row(1,2,3),row(10,9,8);+----------+----------+----------+| column_0 | column_1 | column_2 |+----------+----------+----------+| 1 | 2 | 3 || 10 | 9 | 8 |+----------+----------+----------+2 rows in set (0.00 sec)
多条 VALUES 联合 UNION ALLmysql-(ytt/3305)->values row(1,2,3),row(10,9,8) union all values \ row(-1,-2,0),row(10,29,30),row(100,20,-9);+----------+----------+----------+| column_0 | column_1 | column_2 |+----------+----------+----------+| 1 | 2 | 3 || 10 | 9 | 8 || -1 | -2 | 0 || 10 | 29 | 30 || 100 | 20 | -9 |+----------+----------+----------+5 rows in set (0.00 sec)
根据字段下标排序,从 1 开始mysql-(ytt/3305)->values row(1,2,3),row(10,9,8) union all values \ row(-1,-2,0),row(10,29,30),row(100,20,-9) order by 1 desc ;+----------+----------+----------+| column_0 | column_1 | column_2 |+----------+----------+----------+| 100 | 20 | -9 || 10 | 9 | 8 || 10 | 29 | 30 || 1 | 2 | 3 || -1 | -2 | 0 |+----------+----------+----------+5 rows in set (0.00 sec)
类型可以任意组合:bit,json,datetime,int,decimal 等mysql-(ytt/3305)->values row(100,200,300),\ row('2020-03-10 12:14:15','mysql','test'), \ row(16.22,TRUE,b'1'), \ row(left(uuid(),8),'{"name":"lucy","age":"28"}',hex('dble'));+---------------------+----------------------------+--------------------+| column_0 | column_1 | column_2 |+---------------------+----------------------------+--------------------+| 100 | 200 | 0x333030 || 2020-03-10 12:14:15 | mysql | 0x74657374 || 16.22 | 1 | 0x01 || c86fd1a7 | {"name":"lucy","age":"28"} | 0x3634363236433635 |+---------------------+----------------------------+--------------------+4 rows in set (0.00 sec)
新建表 t3,把刚才这些记录写进去mysql-(ytt/3305)->create table t3 (r1 varchar(100),r2 varchar(100),r3 varchar(100));Query OK, 0 rows affected (0.02 sec)
写入到表 t3mysql-(ytt/3305)->insert into t3 values row(100,200,300), \ row('2020-03-10 12:14:15','mysql','test'), \ row(16.22,TRUE,b'1'),\ row(left(uuid(),8),'{"name":"lucy","age":"28"}',hex('dble'));Query OK, 4 rows affected (0.00 sec)Records: 4 Duplicates: 0 Warnings: 0
2015-07-03
展开全部
简单做
insert into pay_table (userid,goodsid,nub,payoff) values('1','2','3','4');
update user_table set douzi='123',zdouzi='21' where userid='1'
-------------------------
ok执行
语支持:
sql1;sql2;sql3
用号隔ok(能select 语句起用)
说需要返结集种语句 都起执行
用号隔
insert into pay_table (userid,goodsid,nub,payoff) values('1','2','3','4');
update user_table set douzi='123',zdouzi='21' where userid='1'
-------------------------
ok执行
语支持:
sql1;sql2;sql3
用号隔ok(能select 语句起用)
说需要返结集种语句 都起执行
用号隔
追问
你这写的不对吧,貌似你没懂我的意思
我得意思是有个字段的值是一个语句例如:'select PRODUCT_OFFERING_ID value,NAME text from pd.PM_PRODUCT_OFFERING where NAME like \'%:' 这么一大坨就一个values括号里面的一个值,这插入语句转换成oracle的插入语句时是怎样的格式,明白了吧
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询