系统环境 xp+2.0+oracle9i
表结构(由于是测试,表结构随便建了一张) XX
字段名
类型
ID
VARCHAR2(70)
TEST
CLOB
测试
方式1:直接将CLOB的值拼写在SQL语句中。
代码:
string id = Guid.NewGuid().ToString();
OracleCommand cmd = Conn.CreateCommand();
cmd.CommandText = "insert into xx(id,test) values('" + id + "','" + data + "')";// data是一个变量,存储你要插入的字符串
cmd.ExecuteNonQuery();
情况分析:
当data的长度大于4000时报错(ORA-01704:文字字符串过长),小于或等于4000时正常插入。
原因分析:
之所以会出现长度大于4000时报错,是因为Oracle中有SQL语句中两个单引号之间的字符数不能大于4000的限制。'" + data + "' data在sql语句之间,当data的值大于4000个字节时就会报错。
解决办法:
这种方式比较棘手,但有更好的方式,下边会讲到 。
方式2:采用参数形式。
代码:
string id = Guid.NewGuid().ToString();
OracleCommand cmd = Conn.CreateCommand();
cmd.CommandText = "insert into xx(id,test) values('" + id + "',:p1)";
OracleParameter p1 = new OracleParameter("p1", OracleType.Clob);
p1.Value = data; // data是一个变量,存储你要插入的字符串
cmd.Parameters.Add(p1);
cmd.ExecuteNonQuery();
情况分析:
采用这种方式能够正常插入。所以推荐用这种方式。
原因分析:
无
解决办法:
无
方式3:采用参数形式,但是参数类型写为OracleType. NVarChar
代码:
string id = Guid.NewGuid().ToString();
OracleCommand cmd = Conn.CreateCommand();
cmd.CommandText = "insert into xx(id,test) values('" + id + "',:p1)";
OracleParameter p1 = new OracleParameter("p1", OracleType. NVarChar);
p1.Value = data; // data是一个变量,存储你要插入的字符串
cmd.Parameters.Add(p1);
cmd.ExecuteNonQuery();
情况分析:
为什么要写这种方式,因为这种方式和采用NHibernate的方式很相似,先看看在这种方式会产生什么情况。当data的字节数在0-2000之间时正常插入,大于4000时也正常插入,但在2000-4000时则失败,报错(ORA-01461:仅可以插入 LONG列的LONG值赋值)
原因分析:
没有采用对应的Oracle类型。
解决办法:
采用OracleType.Clob
下边采用NHibernate插入数据,NHibernate具体怎用不在本次讨论范围。
NHibernate采用的版本为1.2.1.4000。
下边大至把简要配置写下。
App.config
value="Data Source=Orcl_192.168.0.232;User ID =icqs_test;Password=icqs_test" /> key="hibernate.adonet.batch_size" value="100" /> xx.cs using System; using System.Collections.Generic; using System.Text; namespace Test.Enties { [Serializable] public class Xx { public Xx() { } private string id; public virtual string Id { get { return id; } set { id = value; } }

mysqlviewshavelimitations:1)supportallsqloperations、制限、dataManipulationswithjoinsorubqueries.2)それらは、特にパフォーマンス、特にパルフェクソルラージャターセット

reperusermanmanagementInmysqliscialforenhancingsecurationsinginuring databaseaperation.1)usecreateusertoaddusers、指定connectionsourcewith@'localhost'or@'% '。

mysqldoes notimposeahardlimitontriggers、しかしpracticalfactorsdeTerminetheireffectiveuse:1)serverconufigurationStriggermanagement; 2)complentiggersincreaseSystemload;

はい、それはssafetostoreblobdatainmysql、butonsiderheSeCactors:1)Storagespace:blobscanconsumesificantspace.2)パフォーマンス:パフォーマンス:大規模なドゥエットブロブスメイズ階下3)backupandrecized recized recized recize

PHP Webインターフェイスを介してMySQLユーザーを追加すると、MySQLI拡張機能を使用できます。手順は次のとおりです。1。MySQLデータベースに接続し、MySQLI拡張機能を使用します。 2。ユーザーを作成し、CreateUserステートメントを使用し、パスワード()関数を使用してパスワードを暗号化します。 3. SQLインジェクションを防ぎ、MySQLI_REAL_ESCAPE_STRING()関数を使用してユーザー入力を処理します。 4.新しいユーザーに権限を割り当て、助成金ステートメントを使用します。

mysql'sblobissuitable forstoringbinarydatawithinarationaldatabase、whileenosqloptionslikemongodb、redis、andcassandraofferferulesions forunstructureddata.blobissimplerbutcanslowdowdowd withwithdata

toaddauserinmysql、使用:createuser'username '@' host'identifidedby'password '; here'showtodoitsely:1)chosehostcarefilytoconを選択しますTrolaccess.2)setResourcelimitslikemax_queries_per_hour.3)usestrong、uniquasswords.4)endforcessl/tlsconnectionswith

toavoidcommonMonmistakeswithStringDatatypesinmysql、undultingStringTypenuste、choosetherightType、andManageEncodingandCollationsEttingtingive.1)Usecharforfixed-LengthStrings、Varcharforaible Length、AndText/Blobforlardata.2)setCurrectCherts


ホットAIツール

Undresser.AI Undress
リアルなヌード写真を作成する AI 搭載アプリ

AI Clothes Remover
写真から衣服を削除するオンライン AI ツール。

Undress AI Tool
脱衣画像を無料で

Clothoff.io
AI衣類リムーバー

Video Face Swap
完全無料の AI 顔交換ツールを使用して、あらゆるビデオの顔を簡単に交換できます。

人気の記事

ホットツール

PhpStorm Mac バージョン
最新(2018.2.1)のプロフェッショナル向けPHP統合開発ツール

ドリームウィーバー CS6
ビジュアル Web 開発ツール

ZendStudio 13.5.1 Mac
強力な PHP 統合開発環境

VSCode Windows 64 ビットのダウンロード
Microsoft によって発売された無料で強力な IDE エディター

WebStorm Mac版
便利なJavaScript開発ツール
