mysql,sqlserver,oracle三种数据库的大对象存取
mysql 大对象存取:
类型一般应该用mediumblod,
blob只能存2的16次方个byte,
mediumblod是24次方,
一般来说够用了.longblob是32次方有些大.
MYSQL默认配置只能存1M大小的文件,要修改配置,WIN版本的在mysql.ini文件中
修改max_allowed_packet,net_buffer_length等几个参数,或直接SET GLOBAL varName=value.
linux版本可以在启动参数后加-max_allowed_packet=xxM等几个参数.
MYSQL存大对象最好直接就setBinaryStream,又快又方便.
而不要先插入空再造型成BLOB然后再setBlob
例子:
import java.sql.*;
import java.io.*;
public class DBTest {
static String driver = "org.gjt.mm.mysql.Driver";
static String url = "jdbc:mysql://localhost:3306/test";
static String user = "root";
static String passwd = "passwd";
public static void main(String[] args) throws Exception {
Connection conn = null;
try {
Class.forName(driver);
conn = DriverManager.getConnection(url,user,passwd);
int op = 1;
//插入
if (op == 0) {
PreparedStatement ps = conn.prepareStatement("insert into tb_file values (?,?)");
ps.setString(1, "aaa.exe");
InputStream in = new FileInputStream("d:/aaa.exe");
ps.setBinaryStream(2,in,in.available());
ps.executeUpdate();
ps.close();
}
else {
//取出
PreparedStatement ps = conn
相关文档:
Join是一种试图将两个表结合在一起的谓词,一次只能连接2个表,表连接也可以被称为表关联。在后面的叙述中,我们将会使用”row source”来代替”表”,因为使用row source更严谨一些,并且将参与连接的2个row source分别称为row source1和row source 2。Join过程的各个步骤经常是串行操作,即使相关的r ......
此文章的安装方法适用于Windows XP下的Apache+PHP+MySQL安装。 1. 安装环境
操作系统是 Windows XP 中文版, Apache, PHP, MySQL 的最新版本是截止到 2007.09.07,分别在其官网下载的:
* Apache 2.2.6:http://apache.mirror.phpchina.com/httpd/binaries/win32/
* PHP 5.2.4 (Windows Binaries PHP 5.2.4 z ......
假设有表 tb1
ID | name|
----+--------+
1 |2toon|
2 |1*xyz|
语句1:
select * from tb1 where ID='2toon' or name ='2toon';
mysql服务器在某模式下,可以执行这条句,就成功返回两条记录,原因在于 ID=‘2toon’ 加了单引号,mysql解释为 ID=2.
语句2
select * fro ......
1。 改表法。可能是你的帐号不允许从远程登陆,只能在localhost。这个时候只要在localhost的那台电脑,登入mysql后,更改 "mysql" 数据库里的 "user" 表里的 "host" 项,从"localhost"改称"%"
mysql -u root -p
mysql>use mysql;
mysql>update user set& ......
>>mysql:
1、查看所有表名:
show tables [from db_name];
2、查看字段信息
SHOW FULL COLUMNS from db_name.table_name
获取以下信息
Field :字段名
Type:字段类型
Collation:字符集 (mysql 5.0以上有)
Null :是否可以为NULL
Key:索引(PRI,unique,index)
Default:缺省值
Extra:额外(是否 aut ......