show columns from 商品库存;xxxxxxxxxx columnshow columns from 商品库存;
1 2
select 所在区域 from 商品库存 limit 5; 检索此语句使用SELECT语句检索单个列。LIMIT 5指示MySQL返回 不多于5行。
统计四张表的记录数,要求 SQL 语句禁用联合查询(Union、JOIN、多表
1 2 3
SELECT (SELECTCOUNT(*) FROM d_3_1) AS dcount, (SELECTCOUNT(*) FROM 商品库存) AS scount
一、连接数据库
1
mysql -h 主机IP -P 端口号 -u 用户名 -p 密码
在 Ubuntu
1
MySQL -u root -p
连接远程主机
1
mysql -h110.110.110.110 -u root -p 123;
二、修改用户密码
1
mysqladmin -u root -password ab12
再次修改
1
mysqladmin -u root -password djg345
三、新增用户
(1)增加一个用户 test1,密码为 abc
1 2
grant select,insert,delete on *.*to [email]=test@"%]test1@"[/email]"Indentified by"abc"; # grant on 命令格式:grant select on 数据库.* to 用户名@登录主机 identified by “密码”;
(2)新增一个 test2 密码为 abc,只能 localhost 登录
1 2 3
grant select,insert,update,delete on mydb.* to [email=test2@localhost]test2@localhsot[/email] identified by "abc"; # 如果不想test有密码可以在用一次打消密码 grant select,insert,update,delete on mydb.* to [email=test2@localhost]test2@localhost[/email] identified by “”;=
四、创建数据库
(1)create database 命名;
(2)创建数据库并分配用户
1 2 3 4 5 6
#1 create database 数据库名; #2 create select,insert,update,delete,create,drop,alter on 数据库名.* to 数据库名@loclhost identified by '密码'; #3 select password por '数据名'@'localhost' =old_password('密码');
SELECT 'table1' AS TableName, COUNT(*) AS RecordCount FROM table1 UNION ALL SELECT 'table2' AS TableName, COUNT(*) AS RecordCount FROM table2 UNION ALL SELECT 'table3' AS TableName, COUNT(*) AS RecordCount FROM table3;