MYSQL基础命令_MySQL
1、修改root命令
mysqladmin -u root -p password [newpassword]
注意password 是修改密码的命令
2、远程登录
mysql -u root -h 127.0.0.1 -P 3306 -D demo -p
3、between包含首尾
select * from product where price between 5 and 10
价格在[5,10],包括5和10
4、null值判断
select * from contract where contact_mobile is null
5、模糊匹配
select * from user where name like '%tom%'
%表示任意字符,任意次数
select * from user where name like '_tom'
_ 表示一个字符
6、连接字符串
select concat(name,'(',phone,')') from contract
7、去除字符串空格
select trim(phone) from contract
8、统计
select count(*) from product 包含空值
select count(phone) from product 不包含空值
9、分组
group by 默认约定
group by 子句中列出的每个列都必须是检索列 或者 有效的表达式(不能使聚集函数)
过滤分组
select user_id ,count(*) as orders from orders group by user_id having count(*) >=2
10、子查询作为select字段
select user_name,(select count(*) from orders where orders.user_id = customers.user_id) as orders
from customers
select user_name,(case when add_time > '2014-03-01' then 1 else 0 end) as flag from users
11、插入数据
插入多条
insert into action_detail(action_id,add_time,user_id) values(1,'2014-04-25',9090),(1,'2014-02-30',9090)
从select 中插入
insert into action_detail(action_id,add_time,user_id) select action_id,add_time,user_id from action
12、更新多个值
update product set name='123',phone='010-9890987' where id=9

熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

AI Hentai Generator
免費產生 AI 無盡。

熱門文章

熱工具

記事本++7.3.1
好用且免費的程式碼編輯器

SublimeText3漢化版
中文版,非常好用

禪工作室 13.0.1
強大的PHP整合開發環境

Dreamweaver CS6
視覺化網頁開發工具

SublimeText3 Mac版
神級程式碼編輯軟體(SublimeText3)

熱門話題

本文討論了使用MySQL的Alter Table語句修改表,包括添加/刪除列,重命名表/列以及更改列數據類型。

文章討論了為MySQL配置SSL/TLS加密,包括證書生成和驗證。主要問題是使用自簽名證書的安全含義。[角色計數:159]

文章討論了流行的MySQL GUI工具,例如MySQL Workbench和PhpMyAdmin,比較了它們對初學者和高級用戶的功能和適合性。[159個字符]

InnoDB的全文搜索功能非常强大,能够显著提高数据库查询效率和处理大量文本数据的能力。1)InnoDB通过倒排索引实现全文搜索,支持基本和高级搜索查询。2)使用MATCH和AGAINST关键字进行搜索,支持布尔模式和短语搜索。3)优化方法包括使用分词技术、定期重建索引和调整缓存大小,以提升性能和准确性。

本文討論了使用Drop Table語句在MySQL中放下表,並強調了預防措施和風險。它強調,沒有備份,該動作是不可逆轉的,詳細介紹了恢復方法和潛在的生產環境危害。

本文討論了在PostgreSQL,MySQL和MongoDB等各個數據庫中的JSON列上創建索引,以增強查詢性能。它解釋了索引特定的JSON路徑的語法和好處,並列出了支持的數據庫系統。
