腾讯云授权服务中心
五万用户的选择,您身边的云计算顾问
发布日:2022-02-26 15:02 阅读数:
-u // 指定用户名 -p // 指定密码 -P // 指定端口 -h // 指定主机名
mysql> help For information about MySQL products and services, visit: http://www.mysql.com/ For developer information, including the MySQL Reference Manual, visit: http://dev.mysql.com/ To buy MySQL Enterprise support, training, or other products, visit: https://shop.mysql.com/ List of all MySQL commands: Note that all text commands must be first on line and end with ';' ? (\?) Synonym for `help'. clear (\c) Clear the current input statement. connect (\r) Reconnect to the server. Optional arguments are db and host. delimiter (\d) Set statement delimiter. ego (\G) Send command to mysql server, display result vertically. exit (\q) Exit mysql. Same as quit. go (\g) Send command to mysql server. help (\h) Display this help. notee (\t) Don't write into outfile. print (\p) Print current command. prompt (\R) Change your mysql prompt. quit (\q) Quit mysql. rehash (\#) Rebuild completion hash. source (\.) Execute an SQL script file. Takes a file name as an argument. status (\s) Get status information from the server. system (\!) Execute a system shell command. tee (\T) Set outfile [to_outfile]. Append everything into given outfile. use (\u) Use another database. Takes database name as argument. charset (\C) Switch to another charset. Might be needed for processing binlog with multi-byte charsets. warnings (\W) Show warnings after every statement. nowarning (\w) Don't show warnings after every statement. resetconnection(\x) Clean session context. For server side help, type 'help contents'
mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | sys | +--------------------+ 4 rows in set (0.01 sec)
mysql> use [db_name]; Database changed
mysql> show tables; mysql> show tables from [db_name]; // 查询指定数据库中的所有可用表 +-------------------+ | Tables_in_acgfate | +-------------------+ | accounts | | users | +-------------------+ 2 rows in set (0.01 sec)
mysql> show columns from [table]; +------------+------------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +------------+------------------+------+-----+---------+----------------+ | id | bigint unsigned | NO | PRI | NULL | auto_increment | | created_at | datetime(3) | YES | | NULL | | | updated_at | datetime(3) | YES | | NULL | | | deleted_at | datetime(3) | YES | MUL | NULL | | | username | longtext | YES | | NULL | | | password | longtext | YES | | NULL | | | nickname | longtext | YES | | NULL | | | mail | longtext | YES | | NULL | | | avatar | longtext | YES | | NULL | | | gender | longtext | YES | | NULL | | | level | tinyint unsigned | YES | | NULL | | | join_time | datetime(3) | YES | | NULL | | | silence | tinyint(1) | YES | | NULL | | +------------+------------------+------+-----+---------+----------------+ 13 rows in set (0.01 sec)
SELECT [column] FROM [table]; SELECT [column1], [column2] FROM [table]; SELECT * FROM [table];
SELECT DISTINCT [column] FROM [table]当指定多个列时,DISTINCT 会应用于所有的这些列,也就是多个列的唯一组合,如:
SELECT [column] FROM [table] LIMIT 5; // 查询前5行 SELECT [column] FROM [table] LIMIT 5, 5 // 查询从第6行开始的5条记录
SELECT [table].[column] FROM [table]
按指定列排序
SELECT [column1] FROM [table] ORDER BY [column2] SELECT [column1] FROM [table] ORDER BY [column2] DESC // 按降序排序
SELECT [column1] FROM [table] ORDER BY [column2], [column3] SELECT [column1] FROM [table] ORDER BY [column2] DESC, [column3]
编辑:航网科技 来源:腾讯云
本文版权归原作者所有 转载请注明出处
Copyright © 2011-2020 www.hangw.com. All Rights Reserved 深圳航网科技有限公司 版权所有 增值电信业务经营许可证:粤B2-20201122 - 粤ICP备14085080号
微信扫一扫咨询客服
全国免费服务热线
0755-36300002