在使用sqlserver数据库的OpenRowSet函数时,会遇到三种驱动方式: 1. MSDASQL驱动 SELECT TOP 10 * FROM OPENROWSET('MSDASQL', 'DRIVER={SQL Server};SERVER=xxx;UID=xx;PWD=xxx;', 'select * from AdventureWorks.HumanResources.Employee') 2. SQLNCLI驱
在使用sqlserver数据库的OpenRowSet函数时,会遇到三种驱动方式:
1. MSDASQL驱动
SELECT TOP 10 *
FROM OPENROWSET('MSDASQL', 'DRIVER={SQL Server};SERVER=xxx;UID=xx;PWD=xxx;', 'select * from AdventureWorks.HumanResources.Employee')
2. SQLNCLI驱动
SELECT TOP 10 *
FROM OPENROWSET('SQLNCLI', 'SERVER=xxx;UID=xx;PWD=xxxxx;', 'select * from AdventureWorks.HumanResources.Employee')
3. SQLOLEDB驱动
SELECT TOP 10 *
FROM OpenRowSet('SQLOLEDB', 'xxx'; 'xx'; 'xxx', AdventureWorks.HumanResources.Employee)
先看一下定义
MSDASQL:Microsoft OLE DB Provider for ODBC Drivers
允许在 OLEDB 和 ADO(它在内部使用 OLEDB)上构建的应用程序通过 ODBC 驱动程序访问数据源的技术。
MSDASQL 是用于连接到 ODBC(而不是数据库)的 OLEDB 访问接口。
SQLOLEDB :Microsoft OLE DB Provider for SQL Server,可以看出来SQLOLEDB是连接到数据库sqlserver,而不是ODBC驱动
SQLNCLI10(SQLNCLI):SQL Server Native Client 10.0
SQL Server Native Client的定义:
SQL Server Native Client 是在 SQL Server 2005 中引入的用于 OLE DB 和 ODBC 的独立数据访问应用程序编程接口 (API)。SQL Server Native Client 将 SQL OLE DB 访问接口和 SQL ODBC 驱动程序组合成一个本机动态链接库 (DLL)。为了利用在 SQL Server 2005以及以上的版本的新功能,比如多个活动结果集 (MARS)、查询通知、用户定义类型 (UDT) 或新的 xml 数据类型,那些使用 ActiveX Data Objects (ADO) 的现有应用程序应当使用 SQL Server Native Client OLE DB 访问接口作为其数据访问接口。
如果不需要使用在 SQL Server 2005 及其以后的版本中引入的任何新功能,则不需要使用 SQL Server Native Client OLE DB 访问接口;您可以继续使用当前数据访问接口(通常是 SQLOLEDB)。如果要增强现有应用程序的功能,并且需要使用在 SQL Server 2005 及其以后的版本中引入的新功能,则应当使用 SQL Server Native Client OLE DB 访问接口。
附上 OPENROWSET 语法格式
OPENROWSET <strong>(</strong> { <strong>'</strong><em>provider_name</em><strong>'</strong> <strong>,</strong> { <strong>'</strong><em>datasource</em><strong>'</strong> <strong>;</strong> <strong>'</strong><em>user_id</em><strong>'</strong> <strong>;</strong> <strong>'</strong><em>password</em><strong>'</strong> | <strong>'</strong><em>provider_string</em><strong>' </strong>} <strong>,</strong> { [ <em>catalog</em><strong>.</strong> ] [ <em>schema</em><strong>. </strong>] <em>object</em> | <strong>'</strong><em>query</em><strong>'</strong> } | BULK <strong>'</strong><em>data_file</em><strong>'</strong> <strong>,</strong> { FORMATFILE <strong>=</strong> <strong>'</strong><em>format_file_path</em><strong>'</strong> [ <bulk_options> ] | SINGLE_BLOB | SINGLE_CLOB | SINGLE_NCLOB } } <strong>)</strong> <bulk_options> ::= [ <strong>,</strong> CODEPAGE <strong>=</strong> { <strong>'</strong>ACP<strong>'</strong> | <strong>'</strong>OEM<strong>'</strong> | <strong>'</strong>RAW<strong>'</strong> | <strong>'</strong><em>code_page</em><strong>'</strong> } ] [ <strong>,</strong> ERRORFILE <strong>=</strong> <strong>'</strong><em>file_name</em><strong>'</strong> ] [ <strong>,</strong> FIRSTROW <strong>=</strong> f<em>irst_row </em>] [ <strong>,</strong> LASTROW <strong>=</strong> la<em>st_row </em>] [ <strong>,</strong> MAXERRORS <strong>=</strong> m<em>aximum_errors </em>] [ <strong>,</strong> ROWS_PER_BATCH <strong>=</strong> <em>rows_per_batch </em>] <br><br>[ <strong>,</strong> ORDER ( { column [ ASC | DESC ] } [ <strong>,</strong>...<em>n</em> ] ) [ UNIQUE ] </bulk_options></bulk_options>
参照:http://www.cnblogs.com/w-y-f/archive/2012/05/07/2488474.html

mySqlStringTypesimpactStorageAndPerformanCeaseAsfollows:1)长度,始终使用theSamestoragespace,whatcanbefasterbutlessspace-felfficity.2)varCharisvariable varcharisvariable length,morespace-morespace-morespace-effficitybuteftife buteftife butfority butfority textifforlyslower.3)

mySqlStringTypesIncludeVarChar,文本,char,enum和set.1)varCharisVersAtileForvariable-lengthStringStringSuptOptoPeptoPepecifientlimit.2)textisidealforlargetStortStorStoverStorextorewiteWithoutAdefinedLengthl.3)charlisfixed-Length

MySQLoffersvariousstringdatatypes:1)CHARforfixed-lengthstrings,2)VARCHARforvariable-lengthtext,3)BINARYandVARBINARYforbinarydata,4)BLOBandTEXTforlargedata,and5)ENUMandSETforcontrolledinput.Eachtypehasspecificusesandperformancecharacteristics,sochoose

TograntpermissionstonewMySQLusers,followthesesteps:1)AccessMySQLasauserwithsufficientprivileges,2)CreateanewuserwiththeCREATEUSERcommand,3)UsetheGRANTcommandtospecifypermissionslikeSELECT,INSERT,UPDATE,orALLPRIVILEGESonspecificdatabasesortables,and4)

toadduserInmysqleffectection andsecrely,theTheSepsps:1)USEtheCreateuserStattoDaneWuser,指定thehostandastrongpassword.2)GrantNectalRevileSaryPrivilegesSustate,usiveleanttatement,AdheringTotheTeprinciplelastPrevilegege.3)

toaddanewuserwithcomplexpermissionsinmysql,loldtheSesteps:1)创建eTheEserWithCreateuser'newuser'newuser'@''localhost'Indedify'pa ssword';。2)GrantreadAccesstoalltablesin'mydatabase'withGrantSelectOnMyDatabase.to'newuser'@'localhost';。3)GrantWriteAccessto'

MySQL中的字符串数据类型包括CHAR、VARCHAR、BINARY、VARBINARY、BLOB、TEXT,排序规则(Collations)决定了字符串的比较和排序方式。1.CHAR适合固定长度字符串,VARCHAR适合可变长度字符串。2.BINARY和VARBINARY用于二进制数据,BLOB和TEXT用于大对象数据。3.排序规则如utf8mb4_unicode_ci忽略大小写,适合用户名;utf8mb4_bin区分大小写,适合需要精确比较的字段。

最佳的MySQLVARCHAR列长度选择应基于数据分析、考虑未来增长、评估性能影响及字符集需求。1)分析数据以确定典型长度;2)预留未来扩展空间;3)注意大长度对性能的影响;4)考虑字符集对存储的影响。通过这些步骤,可以优化数据库的效率和扩展性。


热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

Video Face Swap
使用我们完全免费的人工智能换脸工具轻松在任何视频中换脸!

热门文章

热工具

安全考试浏览器
Safe Exam Browser是一个安全的浏览器环境,用于安全地进行在线考试。该软件将任何计算机变成一个安全的工作站。它控制对任何实用工具的访问,并防止学生使用未经授权的资源。

适用于 Eclipse 的 SAP NetWeaver 服务器适配器
将Eclipse与SAP NetWeaver应用服务器集成。

VSCode Windows 64位 下载
微软推出的免费、功能强大的一款IDE编辑器

Atom编辑器mac版下载
最流行的的开源编辑器

SublimeText3 Mac版
神级代码编辑软件(SublimeText3)