如何获取MySQL中最近创建的表的创建时间?
以下是语法-
select table_name, create_time from information_schema.TABLES where table_schema = 'yourDataBaseName' order by CREATE_TIME desc limit 1;
让我们创建第一个表(时间:2019-06-1016:40:51)-
mysql> create table DemoTable1 -> ( -> StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> StudentName varchar(100), -> StudentAge int -> );
现在,我们将创建第二个表,假设5分钟后-
mysql> create table DemoTable2 -> ( -> StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> StudentName varchar(100), -> StudentAge int -> );
现在,我们将获取MySQL中最新创建的表的时间(即DemoTable2,因为它是最近创建的表)-
mysql> select table_name, create_time -> from information_schema.TABLES -> where table_schema = 'web' -> order by CREATE_TIME desc -> limit 1;
输出结果
+--------------+---------------------+ | TABLE_NAME | CREATE_TIME | +--------------+---------------------+ | demotable2 | 2019-06-10 16:45:51 | +--------------+---------------------+ 1 row in set (0.01 sec)
热门推荐
10 香港老妈结婚祝福语简短
11 毕业立体贺卡祝福语简短
12 简短新年年会祝福语
13 评论小品祝福语大全简短
14 恭喜师兄结婚祝福语简短
15 员工集体辞职祝福语简短
16 高中新生祝福语 简短
17 装修祝福语男生搞笑简短
18 生日开业蛋糕祝福语简短