您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

MySQL 虚拟生成列如何与内置函数一起使用?

2024/4/1 11:33:18发布14次查看
可以通过一个示例进行说明,在该示例中,我们在名为“employee_data”的表中创建一个虚拟生成的列。我们知道,可以使用或不使用关键字“virtual”来生成虚拟生成列。
示例mysql> create table employee_data(id int auto_increment primary key, first_name varchar(50) not null, last_name varchar(50) not null, full_name varchar(90) generated always as(concat(first_name,'',last_name)));query ok, 0 rows affected (0.55 sec)mysql> describe employee_data;+------------+-------------+------+-----+---------+-------------------+| field | type | null | key | default | extra |+------------+-------------+------+-----+---------+-------------------+| id | int(11) | no | pri | null | auto_increment || first_name | varchar(50) | no | | null | || last_name | varchar(50) | no | | null | || full_name | varchar(90) | yes | | null | virtual generated |+------------+-------------+------+-----+---------+-------------------+4 rows in set (0.00 sec)mysql> insert into employee_data(first_name, last_name) values('yashpal','sharma');query ok, 1 row affected (0.09 sec)mysql> insert into employee_data(first_name, last_name) values('krishan','kumar');query ok, 1 row affected (0.09 sec)mysql> insert into employee_data(first_name, last_name) values('rakesh','arora');query ok, 1 row affected (0.08 sec)mysql> select * from employee_data;+----+------------+-----------+----------------+| id | first_name | last_name | full_name |+----+------------+-----------+----------------+| 1 | yashpal | sharma | yashpal sharma || 2 | krishan | kumar | krishan kumar || 3 | rakesh | arora | rakesh arora |+----+------------+-----------+----------------+3 rows in set (0.00 sec)
以上就是mysql 虚拟生成列如何与内置函数一起使用?的详细内容。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product