mysql自动填写当前时间,添加索引

mysql自动填写当前时间

在navicat操作界面创建表时,如果需要自动填写时间,可以操作如下

复制代码
CURRENT_TIMESTAMP

为表添加索引

复制代码
ALTER table tableName ADD INDEX indexName(columnName)

追加外键

复制代码
ALTER TABLE tb_commentPhoto ADD CONSTRAINT FK_comment_phone
FOREIGN KEY tb_goodsComment(id) REFERENCES tb_commentPhoto(comment_id);

mysql更新语句、新增列、删除列

复制代码
# 更新
update user set name='张三' where id=111
# 删除
DELETE FROM table_name [WHERE Clause]

# 增加字段
alter table 表名 add column 列名 类型;
# 删除字段
alter table 表名 dropcolumn 列名 ;

联合更新

复制代码
    # 联合更新
    update malluser set master_master_id=3 where master_id in (select a.id from (select id from  malluser where id like '15%')a)  

统计某字段重复数据

复制代码
    # 统计某字段重复数据
    SELECT phone, COUNT(*) AS sumCount FROM malluser GROUP BY phone HAVING sumCount > 1;
相关推荐
t***442310 小时前
MySQL 导出数据
数据库·mysql·adb
翔云12345611 小时前
MySQL主从库复制中,主库如何查找对应日志文件位置
数据库·mysql
Mr_star_galaxy12 小时前
【MySQL基础】视图和权限管理
数据库·mysql
lipiaoshuigood13 小时前
MySQL 数据出海之数据同步方案
数据库·mysql
笨蛋不要掉眼泪14 小时前
Nacos配置中心详解:核心用法、动态刷新与经典面试题解析
java·数据库·后端
@@神农14 小时前
PostgreSQL-SQL语句的执行过程(一)
数据库·sql·postgresql
Andy Dennis15 小时前
一文漫谈数据库存储之索引(B+, B-link, LSM tree等)
数据库·b+树·lsm-tree
CHANG_THE_WORLD15 小时前
字符串定义的汇编分析
汇编·数据库
数据知道15 小时前
PostgreSQL:如何通过progres_fdw跨库关联查询?
数据库·postgresql
v***570016 小时前
MYSQL 创建索引
数据库·mysql