当前位置:  数据库>其它
本页文章导读:
    ▪mysql导入导出数据      从文档中导入到数据库 load data local infile '/tmp/test.txt'  into table db.new  fields terminated by ':'                         //列.........
    ▪v$sql、v$sqlarea、v$sqltext、v$sql_plan      --v$sqltext --Concept:This view contains the text of SQL statements belonging to shared SQL cursors in the SGA. --记录完整的sql,但sql被分片存储 /*  Name             Null? .........
    ▪SQLite处理数据效率问题      1.SQLite 缺省为每个操作启动一个事务,那么如果进行1000次操作则要开启1000个事务,"事务开启 + SQL 执行 + 事务关闭"自然耗费了大量的时间。SQLite的数据库本质上来讲就是一个磁盘上的文件,.........

[1]mysql导入导出数据
    来源: 互联网  发布时间: 2013-11-07
从文档中导入到数据库 load data local infile '/tmp/test.txt'
 into table db.new
 fields terminated by ':'                         //列的分割符
 lines terminated by '\n';                      //行的分割符

load data local infile '/tmp/test.txt'
 into table db.user                               //表列类似/etc/passwd,自己动手建吧!
 fields terminated by ':'                    
 lines terminated by '\n'                 
 (username, password, uid, gid, common, home_dir, shell) ;

从数据库导出到文档 mysql> select username,password,uid from db.new into outfile '/tmp/tao.txt'
                fields terminated by '#'
                lines terminated by '\n';

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

mysql之load data

Name: 'LOAD DATA'
Description:
Syntax:
LOAD DATA [LOW_PRIORITY | CONCURRENT] [LOCAL] INFILE 'file_name'
    [REPLACE | IGNORE]
    INTO TABLE tbl_name
    [CHARACTER SET charset_name]
    [{FIELDS | COLUMNS}
        [TERMINATED BY 'string']
        [[OPTIONALLY] ENCLOSED BY 'char']
        [ESCAPED BY 'char']
    ]
    [LINES
        [STARTING BY 'string']
        [TERMINATED BY 'string']
    ]
    [IGNORE number {LINES | ROWS}]
    [(col_name_or_user_var,...)]
    [SET col_name = expr,...]

The LOAD DATA INFILE statement reads rows from a text file into a table
at a very high speed. The file name must be given as a literal string.

LOAD DATA INFILE is the complement of SELECT ... INTO OUTFILE. (See
http://dev.mysql.com/doc/refman/5.5/en/select-into.html.) To write data
from a table to a file, use SELECT ... INTO OUTFILE. To read the file
back into a table, use LOAD DATA INFILE. The syntax of the FIELDS and
LINES clauses is the same for both statements. Both clauses are
optional, but FIELDS must precede LINES if both are specified.

For more information about the efficiency of INSERT versus LOAD DATA
INFILE and speeding up LOAD DATA INFILE, see
http://dev.mysql.com/doc/refman/5.5/en/insert-speed.html.

The character set indicated by the character_set_database system
variable is used to interpret the information in the file. SET NAMES
and the setting of character_set_client do not affect interpretation of
input. If the contents of the input file use a character set that
differs from the default, it is usually preferable to specify the
character set of the file by using the CHARACTER SET clause. A
character set of binary specifies "no conversion."

LOAD DATA INFILE interprets all fields in the file as having the same
character set, regardless of the data types of the columns into which
field values are loaded. For proper interpretation of file contents,
you must ensure that it was written with the correct character set. For
example, if you write a data file with mysqldump -T or by issuing a
SELECT ... INTO OUTFILE statement in mysql, be sure to use a
--default-character-set option with mysqldump or mysql so that output
is written in the character set to be used when the file is loaded with
LOAD DATA INFILE.

*Note*: It is not possible to load data files that use the ucs2, utf16,
or utf32 character set.

The character_set_filesystem system variable controls the
interpretation of the file name.

You can also load data files by using the mysqlimport utility; it
operates by sending a LOAD DATA INFILE statement to the server. The
--local option causes mysqlimport to read data files from the client
host. You can specify the --compress option to get better performance
over slow networks if the client and server support the compressed
protocol. See http://dev.mysql.com/doc/refman/5.5/en/mysqlimport.html.

If you use LOW_PRIORITY, execution of the LOAD DATA statement is
delayed until no other clients are reading from the table. This affects
only storage engines that use only table-level locking (such as MyISAM,
MEMORY, and MERGE).

If you specify CONCURRENT with a MyISAM table that satisfies the
condition for concurrent inserts (that is, it contains no free blocks
in the middle), other threads can retrieve data from the table while
LOAD DATA is executing. Using this option affects the performance of
LOAD DATA a bit, even if no other thread is using the table at the same
time.

Prior to MySQL 5.5.1, CONCURRENT was not replicated when using
statement-based replication (see Bug #34628). However, it is replicated
when using row-based replication, regardless of the version. See
http://dev.mysql.com/doc/refman/5.5/en/replication-features-load-data.h
tml, for more information.

The LOCAL keyword, if specified, is interpreted with respect to the
client end of the connection:

o If LOCAL is specified, the file is read by the client program on the
  client host and sent to the server. The file can be given as a full
  path name to specify its exact location. If given as a relative path
  name, the name is interpreted relative to the directory in which the
  client program was started.

  When using LOCAL with LOAD DATA, a copy of the file is created in the
  server's temporary directory. This is not the directory determined by
  the value of tmpdir or slave_load_tmpdir, but rather the operating
  system's temporary directory, and is not configurable in the MySQL
  Server. (Typically the system temporary directory is /tmp on Linux
  systems and C:\WINDOWS\TEMP on Windows.) Lack of sufficient space for
  the copy in this directory can cause the LOAD DATA LOCAL statement to
  fail.

o If LOCAL is not specified, the file must be located on the server
  host and is read directly by the server. The server uses the
  following rules to locate the file:

  o If the file name is an absolute path name, the server uses it as
    given.

  o If the file name is a relative path name with one or more leading
    components, the server searches for the file relative to the
    server's data directory.

  o If a file name with no leading components is given, the server
    looks for the file in the database directory of the default
    database.

Note that, in the non-LOCAL case, these rules mean that a file named as
./myfile.txt is read from the server's data directory, whereas the file
named as myfile.txt is read from the database directory of the default
database. For example, if db1 is the default database, the following
LOAD DATA statement reads the file data.txt from the database directory
for db1, even though the statement explicitly loads the file into a
table in the db2 database:

LOAD DATA INFILE 'data.txt' INTO TABLE db2.my_table;

Windows path names are specified using forward slashes rather than
backslashes. If you do use backslashes, you must double them.

For security reasons, when reading text files located on the server,
the files must either reside in the database directory or be readable
by all. Also, to use LOAD DATA INFILE on server files, you must have
the FILE privilege. See
http://dev.mysql.com/doc/refman/5.5/en/privileges-provided.html. For
non-LOCAL load operations, if the secure_file_priv system variable is
set to a nonempty directory name, the file to be loaded must be located
in that directory.

Appendix

http://dev.mysql.com/doc/refman/5.5/en/load-data.html

Share

两个数据库之间相互导入,需要字符集一样!如果是英文的字符集,则无需关注字符集! 字符集相关,分享一个Oracle大师的研究!太厉害了!

(windows \n\r    , linux \n ========>shell>yum install -y dos2unix)
shell>dos2unix test.txt            

    
[2]v$sql、v$sqlarea、v$sqltext、v$sql_plan
    来源: 互联网  发布时间: 2013-11-07
--v$sqltext
--Concept:This view contains the text of SQL statements belonging to shared SQL cursors in the SGA.
--记录完整的sql,但sql被分片存储
/*
 Name             Null?    Type
 ----------------------------------------- -------- ----------------------------
 ADDRESS              RAW(4)
 HASH_VALUE              NUMBER            --address、hash_value唯一标识一条sql
 SQL_ID               VARCHAR2(13)
 COMMAND_TYPE              NUMBER
 PIECE                NUMBER               --PIECE分片之后的顺序
 SQL_TEXT                        VARCHAR2(64)         --SQL_TEXT为sql文本
 */
select * from v$sqltext;

--v$sqlarea
--Concept:V$SQLAREA lists statistics on shared SQL area and contains one row per SQL string. It provides statistics on SQL statements that are in memory, parsed, and ready for execution.
--记录共享sql区中的统计信息(执行次数、逻辑读、物理读等);相同文本的sql只记录一次
/*
 Name             Null?    Type
 ----------------------------------------- -------- ----------------------------
 SQL_TEXT              VARCHAR2(1000)
 SQL_FULLTEXT              CLOB
 SQL_ID               VARCHAR2(13)
 SHARABLE_MEM              NUMBER
 PERSISTENT_MEM             NUMBER
 RUNTIME_MEM              NUMBER
 SORTS                NUMBER
 VERSION_COUNT              NUMBER
 LOADED_VERSIONS            NUMBER
 OPEN_VERSIONS              NUMBER
 USERS_OPENING              NUMBER
 FETCHES              NUMBER
 EXECUTIONS              NUMBER
 PX_SERVERS_EXECUTIONS            NUMBER
 END_OF_FETCH_COUNT            NUMBER
 USERS_EXECUTING            NUMBER
 LOADS                NUMBER
 FIRST_LOAD_TIME            VARCHAR2(76)
 INVALIDATIONS              NUMBER
 PARSE_CALLS              NUMBER
 DISK_READS              NUMBER
 DIRECT_WRITES              NUMBER
 BUFFER_GETS              NUMBER
 APPLICATION_WAIT_TIME            NUMBER
 CONCURRENCY_WAIT_TIME            NUMBER
 CLUSTER_WAIT_TIME            NUMBER
 USER_IO_WAIT_TIME            NUMBER
 PLSQL_EXEC_TIME            NUMBER
 JAVA_EXEC_TIME             NUMBER
 ROWS_PROCESSED             NUMBER
 COMMAND_TYPE              NUMBER
 OPTIMIZER_MODE             VARCHAR2(10)
 OPTIMIZER_COST             NUMBER
 OPTIMIZER_ENV              RAW(797)
 OPTIMIZER_ENV_HASH_VALUE          NUMBER
 PARSING_USER_ID            NUMBER
 PARSING_SCHEMA_ID            NUMBER
 PARSING_SCHEMA_NAME            VARCHAR2(30)
 KEPT_VERSIONS              NUMBER
 ADDRESS              RAW(4)
 HASH_VALUE              NUMBER
 OLD_HASH_VALUE             NUMBER
 PLAN_HASH_VALUE            NUMBER
 MODULE               VARCHAR2(64)
 MODULE_HASH              NUMBER
 ACTION               VARCHAR2(64)
 ACTION_HASH              NUMBER
 SERIALIZABLE_ABORTS            NUMBER
 OUTLINE_CATEGORY            VARCHAR2(64)
 CPU_TIME              NUMBER
 ELAPSED_TIME              NUMBER
 OUTLINE_SID              VARCHAR2(40)
 LAST_ACTIVE_CHILD_ADDRESS                RAW(4)
 REMOTE                         VARCHAR2(1)
 OBJECT_STATUS                        VARCHAR2(19)
 LITERAL_HASH_VALUE                    NUMBER
 LAST_LOAD_TIME                     DATE
 IS_OBSOLETE                        VARCHAR2(1)
 CHILD_LATCH                        NUMBER
 SQL_PROFILE                        VARCHAR2(64)
 PROGRAM_ID                        NUMBER
 PROGRAM_LINE#                        NUMBER
 EXACT_MATCHING_SIGNATURE                NUMBER
 FORCE_MATCHING_SIGNATURE                NUMBER
 LAST_ACTIVE_TIME                    DATE
 BIND_DATA                        RAW(2000)
*/
select * from v$sqlarea

--v$sql
--Concept:V$SQL lists statistics on shared SQL area without the GROUP BY clause and contains one row for each child of the original SQL text entered. Statistics displayed in V$SQL are normally updated at the end of query execution. However, for long running queries, they are updated every 5 seconds. This makes it easy to see the impact of long running SQL statements while they are still in progress.
--记录共享sql区中的统计信息(执行次数、逻辑读、物理读等);每一次执行sql语句都会记录,且与v$sql_plan关联可查询每条sql语句的执行计划。
    
[3]SQLite处理数据效率问题
    来源:    发布时间: 2013-11-07

1.SQLite 缺省为每个操作启动一个事务,那么如果进行1000次操作则要开启1000个事务,"事务开启 + SQL 执行 + 事务关闭"自然耗费了大量的时间。SQLite的数据库本质上来讲就是一个磁盘上的文件,所以一切的数据库操作其实都会转化为对文件的操作,而频繁的文件操作将会是一个很好时的过程,会极大地影响数据库存取的速度。而使用事务将把全部要执行的SQL语句先缓存在内存当中,然后等到COMMIT的时候一次性的写入数据库,这样数据库文件只被打开关闭了一次,效率自然大大的提高。
 

本文链接


    
最新技术文章:
▪gc buffer busy/gcs log flush sync与log file sync    ▪让你的PL/SQL更好用    ▪ADO.NET中的非脱机数据库查询
▪参数job_queue_processes与Oracle jobs    ▪11gR2游标共享新特性带来的一些问题以及_cursor...    ▪_library_cache_advice和latch:shared pool、latch:shared poo...
▪SQL: Date Utility    ▪DB2 分区表增加分区    ▪DB2第一步 — 创建表
▪oracle 数据库    ▪插入10万条记录测试    ▪rebuild index VS. rebuild index online
▪如何处理undo tablespace 表空间太大的问题    ▪ado执行存储过程中包含结果集获取输出参数为...    ▪oracle函数的demo
▪Entity Framework 学习建议及自学资源    ▪存储过程的编写    ▪Linux/Unix shell 自动发送AWR report(二)
▪第二章 Oracle恢复内部原理(基础数据结构)    ▪Redis源码学习之【Tcp Socket封装】    ▪Java Jdbc减少与Oracle之间交互提升批量处理性能...
▪南大通用GBase8a Vs Oracle11g 单机测试亲测    ▪oracle 中行列转换    ▪rhel下安装oracle10g+asm---测试环境搭建
▪Redis系列-主从复制配置    ▪MySQL索引与查询优化    ▪INDEX受到NULL值的影响
▪测试人员的SQL语言 系列    ▪SQL数据库基本语句    ▪MySQL Replication常见错误整理[持续更新...]
▪eclipse下建立esper的demo    ▪把oracle rac 转化为单机数据库    ▪Redis系列-存储篇sorted set主要操作函数小结
▪基本的SQL*Plus报表和命令    ▪druid简单教程    ▪11g调度--scheduler使用
▪EF基础一    ▪db2存储过程中循环语句while do的continue有没有...    ▪oracle 创建DBLINK
▪DB2数据库备份还原    ▪Warning: prerequisite DBD::mysql 1 not found错误解决方...    ▪innotop性能监视mysql,innodb工具
▪数据迁移:DataGuard配置    ▪QX项目实战-19.跨库数据同步    ▪Mysql EXPLAIN
▪Oracle 11g AWR 系列七:Active Session History (ASH) 报...    ▪Oracle 11G新特性(共36个)    ▪父子节点问题
▪OEM简介及按钮乱码问题    ▪NoSql之MongoDB的常用类管理    ▪ORA-39700: database must be opened with UPGRADE option
▪node.js 访问redis数据库,pub/sub    ▪使用DBMS_REDEFINITION在线重定义分区表    ▪SQL Developer 使用问题与解决方法汇总
▪oralce 11g dataguard 概念    ▪ORA-30004 错误处理    ▪oracle分组函数rollup,cube
▪Sql Developer 使用问题与解决方法汇总    ▪Configure Oracle Dataguard Primary-ASM to Physical-ASM    ▪Oracle Data Guard 理论知识
▪Control File 恢复    ▪Oracle数据文件收缩    ▪Oracle 11g AWR 系列五:如何生成 AWR 报告?
▪Wireshark数据包分析实战(第2版)    ▪MySql用户权限控制    ▪db2和oracle查询序列区别
▪更新blob字段的存储过程    ▪MySQLReport分析报告三    ▪DB2中的序列
▪Oracle中DBMS_RANDOM.STRING 的用法    ▪SQL SERVER无法安装成功,sqlstp.log文件提示[未发...    ▪Data Guard 部署物理备库的 10 大注意事项
▪万能数据库查询分析器使用技巧之(九)    ▪SQL 自定义Split函数    ▪视图 v$sql,v$sqlarea,$sqltext,v$sqltext_with_newlines 的...
▪Data Guard Standby_archive_dest 和 Log_archive_dest_n 的...    ▪机房收费系统数据库设计(一)    ▪利用putty的SSH tunnel连接Oracle
▪DBCA建库偶遇ORA-27125    ▪使用PowerPivot建立简单的分析模型    ▪Linux/Unix shell 自动发送AWR report
▪写入到blob字段的存储过程    ▪关于JDBC中ResultSet接口的一点细节探究    ▪Data Guard 配置 Standby Redo Log
▪linux下redis的安装    ▪windows下redis的安装    ▪手动创建数据库步骤(简单翻译官方文档)
▪Ubuntu安装Mongodb    ▪SQL CLR应用    ▪redis的配置文件参数--详细说明
 


站内导航:


特别声明:169IT网站部分信息来自互联网,如果侵犯您的权利,请及时告知,本站将立即删除!

©2012-2021,,E-mail:www_#163.com(请将#改为@)

浙ICP备11055608号-3