数据库脚本样例
来源:互联网 发布:小猪短租 知乎 编辑:程序博客网 时间:2024/06/05 18:30
1、登陆数据库
mysql -uroot -p'xxxxxx' --default-character-set=utf8;
2、导出数据库
mysqldump -uroot -proot fanfou > fanfou0816.sql
导出数据库中表
mysqldump -u 用户名 -p 数据库名 表名> 导出的文件名
mysqldump -u wcnc -p test_db users> test_users.sql
insert into user (Host, User, Password) VALUES('%', 'skysip', PASSWORD('xxxxxx'));
GRANT ALL PRIVILEGES ON *.* TO 'skysip'@'%' IDENTIFIED BY '换成密码' WITH GRANT OPTION;
FLUSH PRIVILEGES
4、丢掉外键
a、show create table ff_menu;
`stop_sale` int(1) NOT NULL DEFAULT '0',
`remove_flag` int(1) NOT NULL DEFAULT '0',
`created_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
KEY `ff_menu_fk_store_idx` (`store_id`),
CONSTRAINT `ff_menu_fk_store` FOREIGN KEY (`store_id`) REFERENCES `ff_store` ( `id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=12 DEFAULT CHARSET=latin1
b、ALTER TABLE ff_menu DROP FOREIGN KEY ff_menu_fk_store;
c、ALTER TABLE ff_menu DROP KEY ff_menu_fk_store_idx;
5、修改字段类型
alter table ff_order change user_id user_id varchar(255) not null;
6、新增字段
ALTER TABLE `ff_menu` ADD `sold_out` INT(1) NOT NULL DEFAULT '0' AFTER `stop_sale`;
7、统计select ip, ctime from tv_snlicense where ctime between '2016-07-29' and '2016-08-11' order by ctime limit 1;
select count(*) from snlicense where ctime between '2016-07-29' and '2016-08-11';
select ip, ctime from tv_snlicense where ctime between '2016-07-29' and '2016-08-11' order by ctime desc limit 1;
select left(ctime,10), count(ip) from snlicense where ctime between '2016-07-29' and '2016-08-11' group by left(ctime,'10');
select count(*) from qyq_stat where call_dur > 0 and (created_time between '2016-08-21' and '2016-09-21');
select sum(call_dur) from qyq_stat where call_dur > 0 and (created_time between '2016-08-21' and '2016-09-21');
select count(*) as 次数, left(created_time,'10') as 日期 from qyq_stat where call_dur > 0 and (created_time between '2016-08-21' and '2016-09-21') group by left(created_time, '10');
select sum(call_dur) from qyq_stat where call_dur > 0 and camera_type=1 and (created_time between '2016-08-21' and '2016-09-21');
1 0
- 数据库脚本样例
- jdbc链接sqlserver数据库执行SQL脚本样例
- 数据库脚本
- 数据库脚本
- 数据库脚本
- 数据库脚本
- 数据库脚本
- shell脚本执行数据库脚本
- 编写数据库脚本
- 数据库升级脚本
- 数据库脚本:Database.sql
- 数据库脚本:System.sql
- VBScript脚本连接数据库
- 自动启动数据库脚本
- Book-SQLSERVER数据库脚本
- 编写数据库脚本
- MySQL数据库升级脚本
- 数据库日志清理脚本
- HDU2266How Many Equations Can You Find(深搜)
- 第七周--项目3-负数把正数赶出队列
- Android IPC机制(一):序列化与反序列化
- BP Neural Network
- Android Studio开发环境创建aidl文件,并生成相应的java文件
- 数据库脚本样例
- cocos2d-x 如何创建新项目
- Android WebView 和 javaScript的互相调用(三)
- 安卓第一行代码个人导读
- [Lintcode]Implement Trie 字典树
- 51Nod-1417 天堂里的游戏(解方程)
- String 堆内存和栈内存
- 第七周--项目4-队列数组
- 怎么生成一个c0001~c9999的ID