Mysql常规操作

技术分享   2025-07-22 19:13   31   0  

1、获取数据表中字段的个数
    
    SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA='shu'j' AND table_name='car_info_detail_201801'

2、更新字段属性:自动更新最后处理时间

    ALTER TABLE data_list  MODIFY COLUMN update_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP

3、添加字段属性:自动更新最后处理时间

    ALTER TABLE `mobilesite` ADD COLUMN update_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP

    ALTER TABLE tablename ADD COLUMN modify_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP

4、查询表中的字段数量

    SELECT COUNT(*) FROM information_schema.columns WHERE table_schema='数据库名' AND table_name='表名' ;
5、mysql -uxxx -p -hdb.xxx.com
    
    use xxx
    show tables;

6、//查看存储的引擎
    show table status from db_name where name='table_name';
    show create table t4
 
7、查看当前的MySQL资源占有量
    show full processlist
Blog comments
No one has commented yet, hurry up and grab a sofa~
create comment
desc:Please speak in a civilized manner and build a harmonious network. Your personal information will not be publicly displayed.