mysql_控制台基本使用
来源:互联网 发布:c语言标准库函数 下载 编辑:程序博客网 时间:2024/04/28 13:59
-- 登录这部分
sql> mysql -u sa - p
sql>123
-- 基本表、数据库的命令使用
sql> show basetables; // 有一个s, 不区分场景
+----------------------------------------+
| Database |
+----------------------------------------+
| information |
| lw_db |
| mysql |
| scujcc |
+----------------------------------------+
sql> use scujcc;
sql> show tables;
+----------------------------------------+
| t_bank |
...
+----------------------------------------+
sql> describe t_bank;
-- 可以看到表结构
sql> select * from t_bank;
-- 可以看到表里所有的数据
-- 基本操作语句的使用
1.查询
基本的统计表单
select * from
(select count(*), if(sum(amt) = NULL, 0, sum(amt)) sum from t_order_info) a //一定要有别名
... b
使用嵌套查询而不是left join, 统计交了此项项目的人员
select (select count(*) from t_order_info where feeitem_id = o.feeitem_id and order_status = 1)
count_person from t_feeitem o // count只能直接作用于数据, 而不能嵌套查询
使用count而不是in或者not in, 统计未支付的人员数量
select (
select count(*) from t_customer_fee_list cust //订单表里的数量非常大, 不能使用in或者not in
where cust.feeitem_id = t.feeitem_id
and (select count(*) from t_order_info
where cust_no = cust.cust_no
and order_status = 1) = 0
) not_pay_num from t_feeitem t;
union 相同主键的数据则融合起来
union all 相同主键的都存在
修改表结构
drop table if exists `t_test_info`;
create table `t_test_info` (
`id` int not null auto_increment comment '编号',
`login_id` varchar(32) not null comment '用户名',
`password` varchar(32) not null comment '密码',
`create_date` date not null default date_format(now(), '%Y-%m-%d' ) comment '创建时间',
`create_time` time not null default date_format(now(), '%H:%i:%s') comment '创建详细时间',
`create_timestamp` datetime not null default date_format(now(), '%Y-%m-%d %H-%i-%s') comment '详细时间',
`remark` varchar(256) not null comment '备注',
primary key (`id`),
unique key (`login_id`) //不能用逗号
) comment '测试表';
alter table `t_order_info` add column `remark` varchar(256) null comment '备注' after `sync_flag`;
alter table `t_order_info` drop column `remark`;
delete from `t_order_info` where id = 1123;
drop table if exists `t_order_info`;
drop database if exists `hello`;
insert, update, delete用于记录, drop用于对象基本类似
- mysql_控制台基本使用
- mysql_基本数据类型
- Mysql_基本操作命令
- MySQL_基本操作语句
- mysql_使用笔记_01
- MySql_数据库触发器的使用
- 深入浅出mysql_索引的设计和使用
- 关于java 的基本开发工具:命令控制台的使用
- MySQL基本操作(控制台)
- 控制台基本指令
- MySQL 控制台基本语句
- MySQL控制台基本命令
- 为什么在php不推荐使用mysql_*的函数?
- oracle控制台基本操作大全
- 【工具】memcached基本控制台操作
- mysql_ auto_increment
- MYSQL_配置
- MySql_安装
- Ubuntu下安装Code Blocks
- Duilib 模态对话框和非模态对话框
- 为Sublime Text安装smali代码语法高亮插件
- hdu_1020_Encoding(模拟)
- JS+CSS弹出框
- mysql_控制台基本使用
- C中的volatile用法
- Target runtime Apache Tomcat v6.0 is not defined.错误解决方法
- Android关于PagerAdapter的使用方法的总结
- 关于ViewRootImpl中measure相关代码的分析
- 互斥锁pthread_mutex_t的使用(转载)
- ubuntu12.04 安装ssh报错的解决方案
- firefox Error downloading
- Android WiFi之SoftAP