-













































: SQL-

: SQL-

̲ͲΠ ²Ƞ

ȯɠ ͲѲҠ Ͳ

˲Բֲ

:

SQL-

: 4

: ..

10, 25 2000 .

.蠠 . .

⠠ - 2000

̲

1....2

2. SQL .5

2.1 DAO.6

2.2 ODBC..6

2.3 JSCRIPT..7

3. ...17

ꅅ..21

 腅.22

1 :

Ӡ 򳠠 - Internet. 泠 .  . Internet, ຠ SQL (Structured Query Language) .

  SQL Oracle, Microsoft SQL Server, Sybase, dbase, Informix, Progress . SQL Microsoft SQL Server 7.0 .

MS SQL Server - 볺 , .

고 -, 糠 , . SQL- ຠ , , , .

볺/ -볺 -   . 볺/ MS SQL Server 7.0 󺠠 Ѡ Windows NT.

Ġ MS SQL Server 7.0 쳠 , 고 OLE-DB ຠ ᔺ ODBC - . ֳ .

SQL Server 7.0 ຠ , . SQL , [] 젠 GUI. , . SQL Server Internet.

SQL Server .   糠 䳠 . , , . , , .

2 : ʲܠ Ƞ SQL SERVER 7.0

  SQL Server 볺 . , . SQL Query Analyzer.

䳿 SQL Server :

1 DB-Library

2 ODBC DAO

DB-Library SQL Server . ³ ODBC, .

, ຠ API, SQL Server. ODBC ( SQL-OLE ) 젠 SQL Server .

  DB-Lib . 䳺 . , .

2.1 òߠ DAO

(Data Access Object ᔺ ) ᔺ, , , . SQL ᔺ DAO - Jet ODBC, ODBC, 고 .

DAO , , ຠ ᔺ.  Add ᔺ, 㳿 ODBC.

- , ODBC.

, DAO 㳺 ADO(ActiveX Data Object ᔺ ActiveX ) .

2.2 òߠ ODBC

Ǡ 砠 Ġ Microsoft ODBC . . Select - , , Ġ 볠 SQL.

ODBC . ODBC - , , . ODBC 㳿 Ġ Access Microsoft. ODBC BD-Lib ຠ , ODBC ຠ SQL , BD-Lib ຠ Ⳡ , .

ODBC .  . ODBC 頠 , 쳠 -/ SQL Server , 볺 . ODBC ຠ .

2.3 JSCRIPT

, SQL Server 7.0 . Ӡ shell OS Windows NT - Java Script . . 젠 . js OS Windows NT. Script :

// ADO Flags

var adLockOptimistic = 3;

var adOpenStatic = 3;

var SQL_DataBase = "DSN=OTSt;UID=sa;PWD=;DATABASE=OTSt"

//var SQL_DataBase = "DSN=OTStt;UID=;PWD="

var oConn;

var oRs;

function db_Connect(){

// Create ADO Connection Object. Use IISSDK OBDC Souce with

// default sa account and no password

oConn = new ActiveXObject("ADODB.Connection");

oConn.Open(SQL_DataBase);

oConn.CommandTimeout=600;

}

function db_Record(SQL){

var oRs;

// Create ADO Recordset Component, and associate it with ADO

connection

oRs = new ActiveXObject("ADODB.Recordset");

oRs.ActiveConnection = oConn;

// Get empty recordset

oRs.Source = SQL;

oRs.CursorType = adOpenStatic; // use a cursor

other than Forward Only

oRs.LockType = adLockOptimistic; // use a locktype

permitting insertions

oRs.Open();

return oRs;

}

function db_Close(){

oConn.Close();

}

function db_Requery(Rec,SQL){

Rec.Close();

Rec.Source = SQL;

Rec.Open();

}

db_Connect();

try {

oRs=db_Record("CREATE TABLE dbo.DBTEST ( String char (30) NULL, Number int NOT NULL DEFAULT (0), Random int NOT NULL DEFAULT (0))");

} catch (e) {

}

oRs=db_Record("SELECT * FROM DBTEST WHERE 0=1");

for(i=0;i<100000;i++){

oRs.Addnew();

oRs("String").value="User"+i;

oRs("Number").value=i;

oRs("Random").value=Math.round(100*Math.random());

oRs.Update();

if(i%10000==0)

WScript.echo("Now in base present "+i+" records");

}

WScript.echo("Completed");

:

String Number Random
User1 1 34
User2 2 12
User3 3 75
. . . . . . . . . . . .

Ӡ Script Connect ຠ SQL Server DBTest .

DSN , ODBC.

UID , , SQL Server ຠ s .

PWD password , .   .

Record DBTest , Random 0 99 .

ʳ 10 000, ຠ 3,5 . ꠠ Number .

Script , SQL Server . 䳠 , , 䳠 頠  . - , SQL Server 

, .

// ADO Flags

var adLockOptimistic = 3;

var adOpenStatic = 3;

var SQL_DataBase = "DSN=OTSt;UID=sa;PWD=;DATABASE=OTSt"

//var SQL_DataBase = "DSN=OTStt;UID=;PWD="

var oConn;

var oRs;

function db_Connect(){

// Create ADO Connection Object. Use IISSDK OBDC Souce with

// default sa account and no password

oConn = new ActiveXObject("ADODB.Connection");

oConn.Open(SQL_DataBase);

oConn.CommandTimeout=600;

}

function db_Record(SQL){

var oRs;

// Create ADO Recordset Component, and associate it with ADO connection

oRs = new ActiveXObject("ADODB.Recordset");

oRs.ActiveConnection = oConn;

// Get empty recordset

oRs.Source = SQL;

oRs.CursorType = adOpenStatic; // use a cursor other than Forward Only

oRs.LockType = adLockOptimistic; // use a locktype permitting insertions

oRs.Open();

return oRs;

}

function db_Close(){

oConn.Close();

}

function db_Requery(Rec,SQL){

Rec.Close();

Rec.Source = SQL;

Rec.Open();

}

function Test(TestNumber, Query, CountTests){

Max=0;

Min=1000000;

Delta=0;

Ave=0;

WScript.echo("Query #"+TestNumber);

for(i=0;i<CountTests;i++){

StartTime=new Date();

db_Requery(oRs,Query);

EndTime=new Date();

Delta=(EndTime-StartTime);

WScript.echo(" Probe #"+i+" Result="+Delta+" ms");

Ave=(Ave*i+Delta)/(i+1);

}

WScript.echo(" Result="+Ave+" ms");

}

db_Connect();

oRs=db_Record("SELECT * FROM DBTEST WHERE 1=0");

Test(1, " SELECT * FROM DBTEST " , 50 );

Test(2 , " SELECT * FROM DBTEST ORDER BY String",50);

Test( 3 ," SELECT * FROM DBTEST ORDER BY Number ",50);

Test (4,"SELECT Sum(Number) FROM DBTEST GROUP BY String",50);

Test(5 , " SELECT Sum(Number) FROM DBTEST GROUP BY

Random",50);

Test( 6 , " SELECT * FROM DBTEST WHERE Number = 99999 " , 50);

Test(7 ," SELECT * FROM DBTEST WHERE String = 'User99999'",50);

Test(8,"SELECT * FROM DBTEST WHERE Number in (SELECT

Number FROM DBTEST ) " , 50 );

Test(9 ,"SELECT * FROM DBTEST WHERE Number in (SELECT

Number FROM DBTEST WHERE String < ' User50000 ' ) ",50);

Test(10 , " SELECT * FROM DBTEST WHERE Number in (SELECT

Number FROM DBTEST WHERE String='User50000')", 50);

Test(11, " SELECT * FROM DBTEST WHERE Number in (SELECT

Number FROM DBTEST WHERE String > ' User10000 ' ) " , 50);

Test(12 , "INSERT INTO DBTEST (String,Number)

VALUES('User30',30) " , 50 );

Test(13 , "DELETE FROM DBTEST (String,Number)

VALUES('User30',30) " , 50);

Test(14 ," DELETE FROM DBTEST " , 1);

db_Close()

Test 볠 50 ຠ , :

StartTime=new Date();

EndTime=new Date();

Delta=(EndTime - StartTime);

Ӡ script 14 - SQL Server. .

12 13 糠 .

14 .

:

1:" SELECT * FROM DBTEST " - ;

2: " SELECT * FROM DBTEST ORDER BY String" - String;

3:" SELECT * FROM DBTEST ORDER BY Number"- -蠠 Number ;

4:"SELECT Sum(Number) FROM DBTEST GROUP BY String"

- Number - String;

5:" SELECT Sum(Number) FROM DBTEST GROUP BY

Random" - Number Random ;

6:" SELECT * FROM DBTEST WHERE Number = 99999 " , Number = 99999;

7:" SELECT * FROM DBTEST WHERE String = 'User99999'" - , String = 'User99999' ;

8 : "SELECT * FROM DBTEST WHERE Number in (SELECT Number FROM DBTEST ) " - ;

9 :"SELECT * FROM DBTEST WHERE Number in (SELECT

Number FROM DBTEST WHERE String < ' User50000 ' ) " - , String < ' User50000 ';

10 : " SELECT * FROM DBTEST WHERE Number in (SELECT Number FROM DBTEST WHERE String='User50000')" - , String = ' User50000';

11 : " SELECT * FROM DBTEST WHERE Number in (SELECT Number FROM DBTEST WHERE String > ' User10000 ' ) "- , String > ' User10000' ;

3 : Ƞ

- script 䳿, 쳠 SQL Server 7.0 Microsoft Access 97.

script Access :

//var SQL_DataBase = "DSN=OTSt;UID=sa;PWD=;DATABASE=OTSt"

var SQL_DataBase = "DSN=OTStt;UID=;PWD="

:

SQL Server 7.0 Access 97
1 2,673 1,81
2 7,781 5,603
3 7,356 5,211
4 8,239 7,54
5 0,903 0,494
6 0,345 0,231
7 0,390 0,287
8 11,207 7,11
9 3,843 2,53
10 0,655 0,507
11 11,469 9,816
12 0,3 0,285
13 0,31 0,22
14 55,62 34,324

糠 Access .

2 3, 4 5, 6 7 ,  ຠ .

String " Number"- .

⠠ 4 5 ࠠ " Number" String Random.

String ຠ String Random

ຠ Integer, .

, 糠 . 10 糠 String - 'User50000' ຠ ꠠ , 堠 'User50000'. 50 ຠ . , 'User10000' ຠ .

12,13 .

.

SQL-. SQL Server 7.0 Oracle 8 :

SQL Server 7.0 Oracle 8
1 2,673 2,71
2 7,781 8,06
3 7,356 8,09
4 8,239 8,75
5 0,903 1,041
6 0,345 0,4
7 0,390 0,432
8 11,207 11,917
9 3,843 4,05
10 0,655 0,78
11 11,469 12,021
12 0,3 0,295
13 0,31 0,291
14 55,62 43,134

SQL Server 7.0 Oracle 8 , Oracle . .

SQL ࠠ Informix.

SQL Server 7.0 Informix
1 2,673 2,11
2 7,781 6,932
3 7,356 7,138
4 8,239 7,934
5 0,903 0,856
6 0,345 0,456
7 0,390 0,471
8 11,207 13,04
9 3,843 4,41
10 0,655 0,748
11 11,469 12,814
12 0,3 0,315
13 0,31 0,31
14 55,62 51,48

, SQL Server 7.0 Informix , . Informix SQL Server 7.0 .

 - , .

   , SQL Server 7.0.

Ⳡ , - Microsoft SQL Server 7.0 , , , , , .

고 - DB-Library ODBC DAO.

SQL Server 7.0 Microsoft Access 97.

SQL- Oracle Informix Microsoft SQL Server 7.0.

script- 볺/ .

ʠ ί ˲ :

1. Microsoft SQL Server 7.0 ³

. 1999 .

2. Teach Yourself Oracle 8 In 21 Days Cary N. Prague

3. Access 97 . 1997.

4. Java . BHV 1996 .

5. PC World 3,7,8 97 ., 1,9 98 .

6. www.techrepublic.com



2012 , .