--port <port> Default: 27017 Specifies the TCP port on which the MongoDB instance listens for client connections.
--username <username>, -u <username> Specifies a username with which to authenticate to a MongoDB database that uses authentication. Use in conjunction with the --password and --authenticationDatabase options.
--password <password>, -p <password> Specifies a password with which to authenticate to a MongoDB database that uses authentication. Use in conjunction with the --username and --authenticationDatabase options.
--db <database>, -d <database> Specifies the name of the database on which to run the mongoexport.
--collection <collection>, -c <collection> Specifies the collection to export.
--fields <field1[,field2]>, -f <field1[,field2]>¶ Specifies a field or fields to include in the export. Use a comma separated list of fields to specify multiple fields.
--csv Changes the export format to a comma-separated-values (CSV) format. By default mongoexport writes data using one JSON document for every MongoDB document.
--out <file>, -o <file> Specifies a file to write the export to. If you do not specify a file name, the mongoexport writes data to standard output (e.g. stdout).
--jsonArray Modifies the output of mongoexport to write the entire contents of the export as a single JSON array. By default mongoexport writes data using one JSON document for every MongoDB document
select* from (select v.sql_id, v.child_number, v.sql_fulltext, v.elapsed_time, v.cpu_time, v.disk_reads, rank() over(orderby v.elapsed_time desc) elapsed_rank from v$sql v) a where elapsed_rank <=10 ORDERBY cpu_time desc;
查看CPU使用率最高及性能查询的语句
1 2 3
set linesize 600 col SQL_TEXT for a500 select*from (select sql_text,sql_id,cpu_time from v$sqlorderby cpu_time desc) where rownum<=10orderby rownum asc;
查看使用频率最高的5个查询
1 2 3 4 5 6
select sql_text,executions from (select sql_text,executions, rank() over (orderby executions desc) exec_rank from v$sql) where exec_rank <=5;
查看消耗磁盘读取最多的sql top5
1 2 3 4 5 6
select disk_reads,sql_text from (select sql_text,disk_reads, dense_rank() over (orderby disk_reads desc) disk_reads_rank from v$sql) where disk_reads_rank <=5;
查看需要大量缓冲读取(逻辑读)操作的查询
1 2 3 4 5 6
select buffer_gets,sql_text from (select sql_text,buffer_gets, dense_rank() over (orderby buffer_gets desc) buffer_gets_rank from v$sql) where buffer_gets_rank<=5;
Oracle阻塞查询
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
with vw_lock AS (SELECT*FROM v$lock) select a.sid, 'is blocking', (select'sid:'||s.sid||' object:'||do.object_name||' rowid:'|| dbms_rowid.rowid_create ( 1, ROW_WAIT_OBJ#, ROW_WAIT_FILE#, ROW_WAIT_BLOCK#, ROW_WAIT_ROW# ) ||' sql_id:'||s.sql_id from v$session s, dba_objects do where s.sid=b.sid and s.ROW_WAIT_OBJ# = do.OBJECT_ID ) blockee, b.sid,b.id1,b.id2 from vw_lock a, vw_lock b where a.block =1 and b.request >0 and a.id1 = b.id1 and a.id2 = b.id2;
用户被锁
查询当前所有用户锁状态及时间
1
select username,account_status,lock_date from dba_users;
解锁
1
alteruser<username> account unlock;
Mysql
mysqldump 备份数据
逻辑备份sql语句
1 2 3
-u 用户名 -p 密码 -A 所有的库
single-transaction INNODB存储引擎的表备份时能够做到数据一致
1
mysqldump -uroot -puplooking -A --single-transaction > /tmp/mysql_bak.sql
lock-all-tables MYISAM存储引擎的表备份时能够做到数据一致
1
mysqldump -uroot -puplooking -A --lock-all-tables > /tmp/mysql_bak.sql