MySQL & mSQL

         


, , . , JDBC, Mysql msql , SQL . JDBC Statement execute() SQL-, . , ResultSet ResultSetMetaData, getMetaData() ResultSet.


, , , , . , , ResultSet: , , .

ResultSet JDBC ResultSet. i , , , . - - JDBC ResultSetMetaData. :

.

NULL .

, .

.

, .

.

, mSQL-JDBC, Exec. SQL, , . 14-6 .


14-6. Exec SQL

import java.sql.*;

public class Exec {

public static void main(String args[]) {

Connection con = null; String sql = "";

for(int i=0; i<args.length; i++) {

sql = sql + args[i];

if( i < args.length - 1 ) {

sql = sql + " ";

}

}

System, out. rintln(": " + sql);

try {

Class.forName("com.imaginary. sql.msql.MsqlDriver").newlnstance();

String url = "jdbc:msql://athens.imaginary.com:1114/db_test";

con = DriverManager.getConnection(url, "borg", "");

Statement s = con.createStatement();

if( s.execute(sql) ) {

ResultSet r = s.getResultSet();

ResultSetMetaData meta = r.getMetaData();

int cols = meta.getColumnCount();

int rownum = 0;

while( r.next() ) { rownum++;

System, out. println("Crpa: " + rownum);

for(int i=0; i<cols; i++) {

System.out.print(meta.getColumnLabel(i+1) + ": ' + r.getObject(i+1) + ", ");

}

System.out.println("");

}

}

else

{

System.out.println(s.getUpdateCount() + " .");

}

s.close();

con.close();

}

catch( Exception,e ) { e. printStackTrace();

}

finally

{

if( con != null )

{

try { con.close();

}

catch( SQLException e ) { }

}

}

}

}

ResultSetMetaData getMetaData(). , , . getColumnCount() getColumnLabel().

SQL

14-6 SQL. , , SQL execute (). true, , false . , true, ResultSet getResultSet(). . , , - , getUpdateCu-unt() , .




, API


Java u JDBC

13 « C++», API MySQL mSQL. , API , . MySQL mSQL , , , Oracle, Sybase , , API . Java- . API, Java DataBase Connectivity API (JDBC), SQL- .

JDBC , , , MySQL, mSQL. , JDBC, Java . , MySQL mSQL, , .

Java . , «Exploring Java» (O'Reilly & Associates, Inc.). , , 8 « », «Database Programming with JDBC and Java» (O'Reilly & Associates, Inc.).




Connect . , . , . - SELECT, INSERT, UPDATE DELETE. JDBC API Connection Statement. Statement SQL- . 14-4 , , Statement.

14-4. mSQL JDBC Statement

import Java, sql.*;

import Java, util.*;

public class Insert {

// , : test_id (int)

// test_val (char(55))

// args[0] - test_id, a args[1] - test_val

public static void main(String argv[]) {

Connection con = null;

ResourceBundle bundle = ResourceBundle.getBundle("SelectResource");

try {

String url = bundle.getString("URL");

Statement stmt;

Class.forName(bundle.getString("Driver"));

//

con = DriverManager.getConnection(url, "borg", "");

stmt = con.createStatement();

stmt.executeUpdate("INSERT INTO test (test_id, test_val) " +

"VALUES(" + args[0] + ", '," + args[1] + ")");

}

catch( SQLException e )

{

e. printStackTrace();

}

finally

{

if( con != null )

{

try { con.close();

}

catch( Exception e ) { }

}

}

}

}

, , , INT test_id, , test_val 55 . , . createStatement() , : SQL-, - Connection. executeUpdate() SQL . , executeUp-date() SQL, . , , , , , .


, , ResultSet. ResultSet , 0 , , . JDBC Statement executeQuery(), executeUpdate(), , ResultSet. executeQuery() ResultSet, , JDBC , . MySQL, mSQL . , , - . 14-5 . . 14-2 test.

14-5.

import Java, sql.*;

import Java, util.*;

public class Select {

public static void main(String argv[]) {

Connection con = null;

ResourceBundle bundle =ResourceBundle.getBundle("SelectResource");

try {

String url = bundle.getString("URL"); Statement stmt;

ResultSet rs;

Class.forName(bundle.getString("Driver")); //

con = DriverManager,getConnection(url, "borg", "");

stmt = con.createStatement();

rs = stmt .executeQuery("SFI FCT* from test ORDER BY test_id");

System, out.print In(" :");

while(rs. next()) {

int a= rs.getInt("test_icT);

String str = rs.getString("test_val");

System.out.print(" = " + a);

System.out.print(" = " + str);

System.out.print("\n");

}

stmt.close();

}

catch( SQLException e )

{

e. printStackTrace();

}

finally {

if( con != null ) {

try { con.close(); }

catch( Exception e ) { }

}

}

}

}

Select ResultSet next(). next() ResultSet . next () ResultSet . JDBC 2:0 (scrollable). ResultSet , previous() . , next () false.





. 14-2. test

. , ResultSet Java, . Select g tInt() test_id int, getString() test_val String. , 1, . , , , , .



JDBC SQLException , - . , . JDBC close(). , , . . . , statement, , . JDBC, , finally. , , .





, , Java. 8 , . , JDBC, , Java . (servlet). , 8, JDBC. Web-, . . , , , doPost() HTTP POST, a de-Get () HTTP GET.

: get post. printComments() , . , : wasNull() . , wasNull() t rue, NULL SQL. , Java, NULL, NULL. wasNull() . . wasNull() , NULL. , NULL 0 getlnt(). , - 0 NULL, wasNull().



III.



API , .



MSQLSQL


CREATE

CREATE TABLE name field_name field_type, [field2 type2, ...]

CREATE SEQUENCE ON table [STEP value] [VALUE value]

CREATE INDEX name ON table ( column, ...)

( ). , , .

CREATE SEQUENCE . - , , mSQL. . . STEP . VALUE .

CREATE INDEX . mSQL , . , , .

CREATE TABLE . mSQL. , . , , (: name char(30) not null). mSQL :

CHAR (length)

. .

DATE

.

INT

-2147483646 2147483647.

MONEY

, . ( 19.99) .

REAL

. +/-4.94-324 +/- 1.79+308.

( length)

. - , .


TIME

.

UINT

. 0 4294967295.

:

length

. CHAR , TEXT , . TEXT, .

NOT NULL

, . .



# '

CREATE TABLE emp_data ( id INT, name CHAR(50) )

# 'checks' '1000' # (1)

CREATE SEQUENCE ON checks VALUE 1000

# 'music',

# 'artist','publisher' 'title'.

CREATE INDEX idxl O.N music ( artist, publisher, title )

DELETE

DELETE FROM table [WHERE clause]

. WHERE, ,

. WHERE , .



# 'olddata'(no ). DELETE FROM olddata

# 'sales', 'year' '1995', DELETE FROM sales WHERE year=1995

DROP

DROP INDEX name DROP TABLE name DROP SEQUENCE FROM table

, mSQL.

DROP - , , SQL. DROP, . . DROP - . : (1) (backup); (2) DROP , , .





# 'oh_no'. DROP TABLE oh_no

# 'my_index' DROP INDEX my_index

# 'counter'.

# 'CREATE SEQUENCE'.

DROP SEQUENCE FROM counter

INSERT

INSERT INTO table [ (column, ...) ] VALUES ( values )

. . , , NULL. , .



# 'people'.

INSERT INTO people ( name, rank, serial_number )

VALUES ( 'Bob Smith', 'Captain', 12345 )

SELECT

SELECT [DISTINCT] columns FROM table [clause]

. SELECT .

, mSQL .

DISTINCT, .

column table, column . , , (, SELECT name FROM people; SELECT people, name FROM people ).

Table1, Table2, Tab-1, .... , mSQL . (, SELECT t1.name, t2.address FROM Iong_table_name=t1, Ionger_table_name=t2 ). clause, SELECT ( ).

:

WHERE

WHERE SQL. . ( ), . :



AND

( 0, 0, 1).

OR

( 1, 0, 0).

()

, .

=

1, , 0. mSQL .

<>

1, , 0.

<=

1, , 0.

<

1, , , 0.

>=

1, , 0.

>

1, , 0.

ORDER BY column [DESC][, column2 [DESC],...]

( ). DESC, , (, SELECT name, age FROM people ORDER BY age DESC ).

value1 LIKE value2

valuel value2 1, . « % », ( ), '_', . , , SQL . , (, SELECT name FROM people WHERE name LIKE 'B%' ).

value1 RLIKE value2

valuel value2, , 1, . Unix (, SELECT name FROM people WHERE name RLIKE '^. *').

value1 CLIKE value2

value1 value2, LIKE (, SELECT name FROM people WHERE name CLIKE 'b%' ).

WHERE , 0 NULL. , SELECT age FROM people WHERE age>10 , 'ages' 10.



# () 'people', 'state' 'I'. SELECT name FROM people WHERE state='MI' # 'mytable'. SELECT * FROM mytable

UPDATE

UPDATE table SET column=value, . . . [WHERE clause]

. , .



# 'John Deo' 'John Doe' 'people'. UPDATE people SET name='John Doe' WHERE name='John Deo'


MySQL SQL


ALTER/MODIFY

ALTER [IGNORE] TABLE table ADD [COLUMN] create_clause

ALTER [IGNORE] TABLE table ADD INDEX [name] (column, . . .)

ALTER [IGNORE] TABLE table ADD UNIQUE [name] (column, . . .)

ALTER [IGNORE] TABLE table ALTER [COLUMN] column SET DEFAULT value

ALTER [IGNORE] TABLE table ALTER [COLUMN] column DROP DEFAULT

ALTER [IGNORE] TABLE table CHANGE [COLUMN] column create..clause

ALTER [IGNORE] TABLE table DROP [COLUMN] column

ALTER [IGNORE] TABLE table DROP FOREIGN KEY key

ALTER [IGNORE] TABLE table DROP INDEX key

ALTER [IGNORE] TABLE table DROP PRIMARY KEY

ALTER [IGNORE] TABLE table MODIFY [COLUMN] create_clause

ALTER [IGNORE] TABLE table RENAME [AS] new_name

ALTER , . , , . ALTER :

ALTER TABLE mytable DROP myoldcolumn, ADD mynewcolumn INT

MySQL , . , , . . , - , , ALTER . IGNORE, , ALTER . , IGNORE .

, , , ALTER:

ADD [COLUMN] create,clause

. create_clause , CREATE (. ). , . ( COLUMN .)


ADD INDEX [ name] (column , ...)

㪠 ⮫殢. ᪮஢ 15 ⮫殢. 뢠 易⥫쭮. ᫨ , 㤥 ࢮ ⮫ ᯨ᪥ ( ᫮ 䨪ᮬ _2, _3 . ., ᫨ 室 㭨쭮).

ADD UNIQUE [name] (column, ...)

筮 ADD INDEX ᪫祭 ⮣, ஢ ࠭஢ 㭨. , ᫨ 짮⥫ ⠥ 祭, 㦥 饥 㭨쭮 , 㤥 뤠 ᮮ饭 訡.

ALTER [COLUMN] column SET DEFAULT value

ALTER [COLUMN] column DROP DEFAULT

, 㤠 祭 㬮砭 ⮫. ᫨ ᯮ ࠧ SET DEFAULT , 祭 㬮砭 㪠 ⮫ ( ᫨ ⮣ ⢮ 祭 㬮砭). ᯮ짮 DROP DEFAULT, 饥 祭 㬮砭 㤠. ⮬ 騥 , ᮧ ⮣ 祭, 묨. (祢 ᫮ COLUMN 易⥫쭮 䥪.)

CHANGE [COLUMN] new_column_name create_clause

MODIFY [COLUMN] create__clause

। ⮫. । ᯮ ⨯ ⮫ 쭮 ⢨ . ࠦ create_clause , CREATE. 砥 ⮫ ⮬, ᯮ ।, ⮫. (ਬ, ALTER TABLE mytable CHANGE name newname CHAR(30) .) । MODIFY 筮 CHANGE, ⮫ , . 祢 ᫮ COLUMN 易⥫쭮 䥪. 騥 ८ࠧ ⨯ 믮 ⮬᪨:

ᥫ ᫠ 饩 ⮩, (ਬ, BIGINT DOUBLE).

᫮ 祭 訬 (ਬ, INTEGER BIGINT).

᫮ 祭 訬 (ਬ, DOUBLE FLOAT). ᫨ 祭 室 । ⨯, ᯮ ᨬ쭮 祭 ⨯ ( 襥 ⥫).



᫮ ⥪⮢ (ਬ, SMALLINT CHAR(5)).

⮢ ᫮ (ਬ, VARCHAR MEDIUMINT). ८ࠧ 楫 ᫮, ᫮ 饩 ⮩. ( 室 ⨯.)

ᨬ ⨯ 訬 (ਬ, BLOB LONG-TEXT).

ᨬ ⨯ 訬 (ਬ, TEXT VARCHAR (255) ). ᫨ 祭 , 祬 ⨯ , ⥪ ᥪ ᮮ⢥⢨ ⮬ ⨯.

८ࠧ, 㯮 (ਬ, TIMESTAMP YEAR), MySQL ⠥ ᤥ , ⮡ ᮢ ࠧ㬭 ८ࠧ. ᯮ짮 CHANGE ८ࠧ 㤥 믮  砥, ⥫⢠ MySQL ᤠ 뤠 ᮮ饭 訡. ⮬, (1) ᤥ १ࢭ । ८ࠧ (2) ஢ 祭 «ࠧ㬭».

DROP [COLUMN] column

⮫ ⠡. । 㤠 ⠡ ⮫ ᮤন. ⢥ ᯮᮡ ⠭ , 㭨⮦ ⠪ ᯮᮡ, - ᯮ짮 १ࢭ . 뫪 ⮫ 㤠. , ⮫ ⢥, ⠪ 㭨⮦. (祢 ᫮ COLUMN 易⥫쭮 䥪.)

DROP INDEX key

⠡. । ⠡. । ஭ ᠬ ⠡, ⮫쪮 . ⮬ , 㤠 ⠪ ᯮᮡ, ᮧ ALTER TABLE ... ADD INDEX.

DROP PRIMARY KEY

DROP INDEX . ᯥ樠 , 뢠 ࢨ 箬 (Primary Key). ᫨ ⠡ ࢨ , 㤥 㤠 㭨 .

RENAME [AS] new_table

⠡. ⠡. ᫨ । ਬ , 㣨 ALTER TABLE ஢, MySQL ᮧ ६ ⠡, 砥 㣨 ஢, 믮 ஥ २ ⠡ 䠩 ஢ Unix.



FOREIGN KEY (譨 ) 騩 ন MySQL. ᨭ⠪ ᠭ, ⢨ 譨 箬 ந 㤠.

⮡ ਬ  ⢨ ALTER TABLE , ࠢ SELECT, INSERT, DELETE, UPDATE, CREATE DROP 塞 ⠡-.



# 'address2' ⠡ 'people' . ⨯

# 'VARCHAR' ᨬ쭮 200 ᨬ.

ALTER TABLE people ADD COLUMN address2 VARCHAR(100)

# ⠡ 'hr',

# 'salary'

# 㭨 'id'. த 믮, ᫨

#

# 㡫㥬 祭 ᮧ 'id_idx' (祭 ᭮!).

ALTER TABLE hr ADD INDEX salary_idx ( salary )

ALTER IGNORE TABLE hr ADD UNIQUE id_idx ( id )

# 祭 㬮砭 'price' ⠡ 'sprockets'

# $19.95.

ALTER TABLE sprockets ALTER price SET DEFAULT '$19.95'

# 祭 㬮砭 'middle_name' ⠡ 'names'.

ALTER TABLE names ALTER middle_name DROP DEFAULT

# ⨯ 'profits' 砫쭮 祭 (,

# , 뫮 INTEGER) BIGINT.

ALTER TABLE finanaces CHANGE COLUMN profits profits BIGINT

# 'secret_stuff' ⠡ 'not_private_anymore'

ALTER TABLE not_private_anymore DROP secret_stuff

# 㤠 'id_index' ⠪ ࢨ

# ⠡ 'cars'.

ALTER TABLE cars DROP INDEX id_index, DROP PRIMARY KEY

# २ ⠡ 'rates_current' 'rates_1997'

ALTER TABLE rates_current RENAME AS rates_1997

CREATE

CREATE DATABASE dbname

CREATE TABLE name ( field_name field__type, ... )

CREATE INDEX name ON table ( column, ...)

CREATE FUNCTION name RETURNS values SONAME library

( ). । ᯮ ᮧ , ⠡ 㭪権, ।塞 짮⥫ (UDFs).



CREATE INDEX ন ᮢ⨬ 㣨 ॠﬨ SQL. SQL 祣 믮﫠. ᨨ 3.22 । ⭮ ALTER TABLE ADD INDEX. ⮡ 믮 CREATE INDEX , ࠢ INDEX ⮩ ⠡.

CREATE DATABASE ᮧ . ⨫ mysqladmin . ᪥ mysqladmin, ࠢ MySQL (筮 root mysql) 믮 ⮩ .

CREATE FUNCTION । MySQL ४஢ 믮塞 㭪. 㭪樨 믮 ࠪ᪨ 樨, ⠪ ஥ 짮⥫. 頥 祭 STRING ᨬ ; REAL ᥫ 饩 ⮩ INTEGER 楫 ᥫ. MySQL ८ࠧ 頥 祭 -㭪権 㪠 ⨯. ⥪, ᮤঠ 㭪, ⠭⭮ ࠧ塞 ⥪, MySQL ᪨ ᮥ ࢥ.

CREATE TABLE । ⠡ . ⨬ ஬ ᮧ ⠡ MySQL. । ⮨ ⠡,  ⢮ । . ⠪ । 砥 ᥡ , ⨯,  䨪 (ਬ: name char(30) not null ). MySQL ন ᫥騥 ⨯ , ।⠢ ⠡ 15-1.

15-1.



( )



TINYIN'I ( length)/ INT1( length)

1

祭 0 255 -128 127 .

SMALLINT ( length)/

2



INT2( length)



0 65535 -32768 32767 .

MEDIUMINT ( length)/

3



INT3( length)/



0 16777215

MIDDLEINT ( length)



-8388608 8388607 .

INT (length)/

4



INTEGER ( length)/



0 4294967295

INT4( length)



-2147483648 8388607 .

BIGINT (length)/

8



INT8( length)



0 184467447370955165 -





-9223372036854775808





9223372036854775807 -





.

FLOAT/FLOAT (4)/ FLOAT

4

᫮ 饩 ⮩

(length, decimal )/ FLO-



ᨬ 祭

AT4( length, decimal )



+/-3.40282346638 -





( 㫥) 祭





+/-1.175494351-38.

DOUBLEPRECISION

8

᫮ 饩 ⮩

(length, decimal )/



ᨬ 祭

DOUBLE ( length, decimal )/



+/-1.7976931348623157308

REAL (length, decimal )/



( 㫥) -

FLOAT8( length, decimal )/



+/-2.2250738585072014-308.

FLOAT (8)





DECIMAL ( length, decimal )/

length

᫮ 饩 ⮩ -

NUMERIC ( length, decimal )



祭 ⨯ DOUBLE, ஥ ࠭ CHAR . DECIMAL NUMERIC ᥣ 業 CHAR , ᮤঠ ஢ 祭.

TIMESTAMP (length)

4

祭 timestamp, ஥ ࠧ, . ਯ 祭 . ਯ뢠 祭 NULL ⥪饥 ६. (易⥫쭮) । 譨 ଠ . 14 (祭 㬮砭) 뢮 ப ⨯ ' YYYYMMDDHHMMSS' , 12 flacT'YYMMDDHHMMSS',' 8- 'YYYYMMDD', 6 뤠 'YYMMDD'.

<


DATE

3

祭 , ஥ ࠭ , . 祭 ᥣ 뢮 ଠ 'YYYY-MM-DD',  ᫥ ଠ⮢: 'YY-MM-DD', 'YYYY-MM-DD', 'YYMMDD' 'YYYYMMDDHHMMSS' (, ࠭ ६, ).

TIME

3

祭 ६, ࠭饥 , ᥪ㭤. 祭 ᥣ 뢮 ଠ ': MM: SS',  ᫥ ଠ⮢: ': MM: SS', 'HHMMSS', '' (ᥪ㭤 ࠢ '00'), '' ( ᥪ㭤 ).

DATETIME

8

࠭ ६. 祭 뢮 ଠ 'YYYY-MM-DD HH: MM: SS'.

YEAR

1

祭, ࠭饥 . ଠ 'YYYY', 'YY', 㤥 뢥 姭, 姭 , ᨬ ଠ . 姭 室 1970 2069 ⥫쭮. ⨯ 饥 ६ ন 1901 2155.

CHAR (length) / (length-)

length

ப 䨪஢ .  ⥪ 襩 㤥 ஡ ப. ஡, ⠢ MySQL, 짮⥫, 㤠 뢮 祭. MySQL 㬮砭 ⠥ ⥪ ⢨⥫ ॣ (. 䨪 BINARY ). BINARY ⥭ CHAR 䨪஬ BINARY .

CHAR (length) VARYING/ VARCHAR (length)/ VARBINARY ( length)

length

⮢ ப ६ (⢨⥫쭠 ॣ) ⠭ ᨬ쭮 . ᨬ쭠 1 255 ᨬ. 楢 ஡ 㤠 ࠭ ⮣ ⨯. VARBINARY ⥭ VARCHAR BINARY 䨪஬.

TINYTEXT

length+1

⮢ (⢨⥫쭮 ॣ) ᨬ쭮 255 ᨬ.

TINYBLOB

length+1

筮 (⢨⥫쭮 ॣ) ᨬ쭮 255 ᨬ. ⢨⥫ ॣ.

TEXT/LONG VARCHAR

length+2

⮢ ᨬ쭮 64 ⥪.

BLOB/LONG VARBINARY

length+2

筮 ᨬ ࠧ஬ 64 .

MEDIUMTEXT

length+3

⮢ ᨬ쭮 16 ⥪.

MEDIUMBLOB

length+3

筮 ᨬ ࠧ஬ 16 .

LONGTEXT

length+4

⮢ ᨬ쭮 4 ⥪.

LONGBLOB

length+4

筮 ᨬ ࠧ஬ 4 .

ENUM

1,2

, ஥ ᮤঠ 祭 ।⥫쭮 (ਬ ENUM ("apples", "oranges", "bananas")). ⥪⮢ 祭 ᫮, ᮮ⢥饥 ⮢ ( ࢮ 1). ᥣ ᥭ 祭 NULL. () ᮤঠ 65535 ࠧ ⮢. ᫨ 256 ⮢, ⮫쪮 ( ࠧ ࠢ ⠬).

<


SET

1-8

ᮤঠ  ⢮ ।⥫쭮 祭 (ਬ SET ("rock," "pop," "country," "western")). ᯨ᮪ ࠧ 묨 祭 筮 ⮢ ।⠢ 祭 (ਬ 12, . . 1100 筮 , ⭮ "country, western" ।饬 ਬ). 64 ⮢.

᭮ ⨯ ᯮ짮 䨪.

decimal

ᨬ쭮 ⢮ ࠢ ⮩ ᫥ 饩 ⮩.  祭 ஡ 㤥 㣫. ਬ, price FLOAT(5,2) 祭 4.34 㤥 4.34, 祭 234.27 㤥 234.3 ( ᮮ⢥⢨ 饩 ᨬ쭮 ), 祭 3.331 㤥 룫拉 3.33 ( ᮮ⢥⢨ ᨬ쭮 ஡ ).

length

⢮ ᨬ ᫮ 祭, 뢠 짮⥫. 砥 , ᯮ. ਬ, peanuts INT(4) ⨬ -999 9999. MySQL ࠭ 祭, 室騥 । , 멤 । ᨬ쭮 ࠧ ᢮ ⨯. ᫨ ࠭ 祭 , MySQL 뤠 ।०, 㤥 㭪樮஢ ଠ쭮.

ᯮ짮 ⨯ TIMESTAMP 䨪 length । ଠ, ᯮ㥬 timestamp.

ᯮ짮 ᨬ묨 (⥪⮢묨) ⨯ length । ⢮ ᨬ. ᨬ ⨯ 䨪஢ length 筮 ᫮ ᨬ, ᯮ㥬 ࠭ . ⥪⮢ ⨯ ६ length ᨬ쭮 ப.

ਡ length  易⥫ ⨯, ஬ DECIMAL/NUMERIC , CHAR VARCHAR .

᪮ ⨯ DECIMAL/NUMERIC ࠭ ᨬ쭠 ப, ࠭祭 ᨬ쭮 筮 ⠪ , CHAR. ⮬ ᥫ 㪠 맮 ⠪ 訡, ᫨誮 ப CHAR.



precision

ਡ 㯥 ⨯ FLOAT 楫 ᮢ⨬ ⥬ ODBC. 祭 ⮣ ਡ, ࠢ 4, 㪠뢠 筮 ⢥ ᫮ ( , FLOAT ਡ 筮), 祭 8 । ᫮ 饩 ⮩ 筮 ( , DOUBLE).

AUTO_INCREMENT

ਡ ⮬᪨ ᫮ . 㤮 ᮧ 㭨 䨪஢ ᥩ ⠡. ᠭ ⠭ ⠪ , 筮, 祭 NULL 0 饥 祭 ⮬᪨ 㢥稢 . 饥 祭 AUTO_INCREMENT 祭 㭪樨 LAST_INSERT_ID (. SELECT ).

BINARY

ਡ ᯮ ⨯ CHAR VARCHAR- 㪠 ⥪⮢ ப. ⢥ 䥪⮬ ⮣ ਡ 㤥 ⢨⥫쭮 ॣ ஢ . 㬮砭 MySQL ॣ ஢ ⥪.

DEFAULT value

ਡ ਯ뢠 祭 㬮砭. 祭 㤥 ᢮ 砥, ᫨ ⠡ ⮥. ᫨ 祭 㬮砭 । ࠭祭 NOT NULL , 㤥 ᠭ 祭 NULL. 砥 NOT NULL MySQL 祭 ᭮ ⨯ .

NOT NULL

ਡ ࠭, ⮫ 㤥 -, ⫨筮 NULL, 祭. ⪠ ⠢ ⠪ 祭 NULL 맮 訡.

NULL

ਡ 㪠뢠 ⨬ 祭 NULL. ਡ 㬮砭 砥, ᫨ ਡ 㪠. , 室騥 ⠢ , ਡ NULL. ( 㤥 ந஢, ᫨ 㪠.)

PRIMARY KEY

ਡ ⮬᪨ ࢨ 箬 ⠡. ⮫쪮 ࢨ (. ).  , 饥 ࢨ 箬, ਡ NOT NULL.

REFERENCES table [(column, . . . )] [MATCH FULL | MATCH PARTIAL] [ON



DELETE option] [ON UPDATE option]

ਡ 饥 ६ 䥪. MySQL ᨭ⠪ , ࠡ뢠 . 䨪 ন 祭 SQL ࠧ 筨. ⠪, ᫥ MySQL 㤥 ন 㭪.

UNSIGNED

ਡ ᯮ 楫᫥묨 ⨯ 㪠 楫. ᨬ쭮 祭 楫 ॢ室 ᢮ , ࠭ ⥫ ᫠. 䨪 ⨯ 묨.

ZEROFILL

ਡ ᯮ 楫᫥묨 ⨯ 㫥 । ᫮, 㤥 ⨣ , ᨬ쭠 ⨯. ਬ, counter INT(5) ZEROFILL ᫮ 132 00132.

Indexes

MySQL ন 楯 ஢ ⠡, ᠭ 2, «஥஢ ». ᮧ ।⢮ ᮡ «⨯», 祭 । ⠡.

KEY/INDEX [name] (column, [column2, . . . ])

⮫殢 . (KEY INDEX ⮬ ⥪ ᨭ.) ( 易⥫쭮). ᫨ 㪠, 㤥 ਯᠭ , ᭮ ࢮ ⮫, , ᫨ 室 ঠ 㭨쭮, 㤥 . ᫨ 室 ⮫, ⮫ ᫥ ꥤ 㯯 ந஢. ᫥饥 । : INDEX idxl ( name, rank, serial );

ᮧ ⮣ ந஢ ᫥騥 㯯 ⮫殢:

name, rank, serial

name, rank name

PRIMARY KEY

ࢨ . ࢨ - ᮡ , ⮫쪮 ⠡. , ࢨ - 㭨 (UNIQUE) «PRIMARY». ᬮ ਢ஢ , 㭪樮  㣮 㭨 .



UNIQUE [nm] (column, [column2, . , . ])

ᮡ , 室騥 祭 ண 㭨묨 ( ᮮ⢥⢥ 㭨 ஢ ). ⪠ 饥 祭 㭨 맮 訡. ᮧ 㭨 «nicknames»:

UNIQUE (nicknames);

饩 ॠ樨 ஢ MySQL 祭 NULL ᪠ , 室 .

஢ ⥪⮢ (CHAR, VARCHAR ᨭ) ஢ ⮫쪮 ࢮ ᥣ . ਬ, ᫥ ᮧ ᫮ 'id' 묨 20 ᨬ ⥪⮢ 'address':

INDEX adds ( id, address(20) );

믮  ᪠ 'address' ࠢ ᯮ짮 ⮫쪮 20 ᨬ , ᮢ. ⮬ 让 먣 ந⥫쭮, ᫨ ᯮ짮 ஢ ⮫쪮 ஥ ⢮ ᨬ ⥪⮢ , , 襬 , 㭨 祭.

, 室騥 , । ਡ⮬ NOT NULL (. ). ᮧ ⤥쭮 MySQL ᣥ 訡, ᫨ NOT NULL 㪠. । ࢨ筮 ਡ PRIMARY KEY ᠭ ⠡, ਡ NOT NULL 㤥 ⮬᪨ ( ।०), ᫨ 㪠 .

ᠭ MySQL ᮤন ᫥騥 ᯥ樠 «⨯»:

FOREIGN KEY ( name (column, [column2, . . . ])

CHECK

祢 ᫮ 믮 ⢨. ⥭ SQL-, ᯮ஢ 㣨 . 㭪樮쭮 ᫥騥 ᨨ MySQL.

ࠢ CREATE , ᯮ । CREATE TABLE .



# 'employees'



CREATE DATABASE employees;

# ⠡

CREATE TABLE empjata ( id INT, name CHAR(50) );

# 㭪 make_coffee ( ࠭ ⥪ myfuncs.so

# 頥 ப 祭).

CREATE FUNCTION make_coffee RETURNS string SONAME "myfuncs.so";

DELETE

DELETE FROM table [WHERE clause]

⠡. ᯮ짮 । WHERE 㤥 㤠 ⠡, ⥬ 㤥 ᮧ ⠡. ᯮ짮 WHERE 㤠 , ⢥騥 ᫮ ࠦ. । DELETE 頥 짮⥫ ⢮ 㤠 ᥩ.

᪠ , ᯮ짮 ࠦ WHERE, 㤥 㤠 ⠡. 䥪⨢ ⮤ ⥫쭮 ॥, 祬 㤠 ⤥쭮. ᯮ짮 ⮣ ⮤ MySQL ୥ 짮⥫ 祭 0, ⠪ ᯮᮡ 㧭 ⢮ 㤠 ᥩ. 饩 ॠ樨 ⮤ 㤠 䠩, ⭮騥 ⠡, ஬ 䠩 ।. ⮬ ⮤ 㤮 㫥 ⠡ 쥧 ०묨 묨 ( ⠭). , ⠡ 㤥 ࠭.

ᯮ짮 ᫥饣 ࠦ ࠢ DELETE .



# ⠡ 'olddata1 ( ᠬ ⠡).

DELETE FROM olddata

# ⠡ 'sales', 'year' ࠢ '1995'.

DELETE FROM sales WHERE year=1995

DESCRIBE

DESC

DESCRIBE table [column] DESC table [column]

뤠 ଠ ⠡ ⮫. ࠡ⠥ ᠭ, 㭪樮 ( 㣨) 㯭 SHOW. DESC ন ᪫⥫쭮 ᮢ⨬ Oracle SQL. ⮫ ( 易⥫쭮) ᮤঠ ⠭ SQL, ⮬ 砥 㤥 뤠 ଠ 室 ⮫.



# ⠡ 'messy'

DESCRIBE messy

# ଠ ⮫ ⠡ 'big1 稭 'm_'.



# ' '  ⠪ ⠭ ᫥ ,

# 㪢쭮 㯮ॡ.

DESC big my\_%

DROP

DROP DATABASE name

DROP INDEX name

DROP TABLE [IF EXISTS] name[, name2, ...]

DROP name

, ⠡, 㭪 ⥬ MySQL. .

DROP DATABASE

䠩, 易 . 짮⥫ 頥 ⢮ 㤠 䠩. 設⢮ ⠡ ।⠢ ६ 䠩, 筮 頥 祭 ࠢ ⠡, 㬭 . 믮 ⨫ mysqladmin drop. 믮 , ⠪ ᪥ ⨫ mysqladmin, ࠢ MySQL (筮 root mysql).

DROP INDEX

ন ᮢ⨬ 㣨 ॠﬨ SQL. SQL 祣 믮. ᨨ 3.22 । ⭮ ALTER TABLE . . DROP INDEX. 믮 DROP INDEX ࠢ SELECT, INSERT, DELETE, UPDATE, CREATE DROP ⮩ ⠡.

DROP TABLE

ࠥ ⠡. ⥪饩 ॠ樨 MySQL 㤠 易 ⠡楩 䠩. ᨨ 3.22, 㪠 IF EXISTS , ⮡ MySQL 頫 訡 ⪥ 㤠 ⠡. 믮 ⮩ 樨 室 ࠢ DELETE ⠡.

DROP FUNCTION

짮⥫ 楤 믮塞 MySQL. ⮬ 䠩 ⥪, ᮤঠ騩 楤, 㤠. ᥣ 㭪 ᭮ CREATE FUNCTION . ⥪饩 ॠ樨 DROP FUNCTION 㤠 짮⥫ 㭪 ⠡ 㭪権 MySQL, ᫥饩 ᥬ ⨢஢묨 㭪ﬨ.

믮 ⮩ 樨 室 ࠢ DROP ⠡.

DROP - , , ᠬ ᭮ ࠦ SQL. ᫨ ࠢ 믮 DROP, ⠡ 楫 . ந ।० ⢥ত. ⢥ ᯮᮡ ⬥ DROP - ⠭ १ࢭ . ࠫ  ⠪: (1) ᥣ ࠭ १ࢭ (backup); (2) ᫨ 祬- 㢥७, - ᯮ DROP; (3) ᥣ ࠭ १ࢭ .







# 'important_data'.

DROP DATABASE important_data

# ⠡ 'oh_no', 'help_me' 'dont_do_it'

DROP TABLE oh_no, help_me, dont_do_it

# 'my_index' DROP INDEX my_index

# ࠡ饣 ࢥ 㭪 'myfunc'.

# ⭮  CREATE FUNCTION.

DROP myfunc

EXPLAIN

EXPLAIN SELECT statement

뢮 ଠ 浪 믮 SELECT. । 䥪⨢ ᯮ짮 祩.



EXPLAIN SELECT customer.name, product.name FROM customer, product,

purchases

WHERE purchases.customer=customer.id AND purchases.product=product.id

FLUSH

FLUSH option[, option...]

१᪠ ࠧ ७ 뢠 , ᨬ 㪠 ࠬ. 믮 ⮩ 樨 室 ࠢ reload . ⨬ ᫥騥 ࠬ:

HOSTS

⠡ , ࠭ ଠ ᪨ ⮢. ࠬ ᫥ ᯮ짮, ᫨ IP- 訡, 騥 ⠭ 裡 ⮬.

LOGS

뢠 䠩 ୠ 뢠 . ᯮ ᬥ ᭮ ਯ. ᫨ ୠ ᮡ ७, 䠩 㤥 ७, 㢥祭 .

PRIVILEGES

१㦠 ७ ⠡ ࠧ襭 MySQL. 㯫 ᨫ , ᤥ ⠡.

STATUS

६, ᫥ ﭨ ࢥ.

TABLES

뢠 ⠡ 뢠 ஢ .

GRANT

GRANT privilege [ (column, ...) ] [, privilege [( column, ...) ] ...]

ON {table} TO user [IDENTIFIED BY 'password']

[, user [IDENTIFIED BY 'password'] ...] [WITH GRANT OPTION]

ᨨ MySQL 3.22.11 GRANT ᯮ, 믮. ⥪ 㭪樮쭮 . 짮⥫ ( 짮⥫) ࠢ 㯠. ।⠢ ࠢ 㯠 , ⠡ ⤥ ⮫. ࠬ table 㪠 ⠡ ⥪饩 ; '*', ⮣ ।⠢ ࠢ ⠡ ⥪饩 ; '*. *' - ࠢ ⠡ ; 'database. *', 㤥 䥪 ⠡ 㪠 .



騩 ন ᫥騥 ࠢ:

ALL PRIVILEDGES/ALL

ࠢ 㯠.

ALTER

⠡.

CREATE

⠡.

DELETE

ᥩ ⠡.

DROP

⠡ 楫.

FILE

㤠 楫 , ⠪ ࠢ 䠩 ୠ.

INDEX

㤠 ᮢ ⠡.

INSERT

⠡.

PROCESS

襭 ⮪.

REFERENCES (ࠢ筨)

ॠ.

RELOAD

ࠧ ७ ⠡ (. FLUSH).

SELECT

⥭ ⠡.

SHUTDOWN

몫祭 (Shut down) ࢥ .

UPDATE

䨪 ᥩ ⠡.

USAGE

ࠢ.

६ user user@hostname (짮⥫@ ). user, hostname ᥡ ⠭ SQL. ᯮ짮 祭 窨 , ⮫쪮 ⠭묨 (ਬ, joe@"%. com" «joe@%.com» ࠢ). ᯮ짮 user hostname ࠢᨫ쭮 ᯮ짮 user@«%».

᫨ ࠢ GRANT, 㪠 易⥫ ࠬ INDENTIFIED BY . ᫨ 뢠 짮⥫ , 㤥 ᮧ 㪠 ஫. 㤥 ஫ 饣 짮⥫.

ࠢ GRANT ᯥ䨪 WITH GRANT OPTION . ᫥ 믮 짮⥫ ᬮ ।⠢  ࠢ 㣮 짮⥫.

INSERT

INSERT [DELAYED | LOW_PRIORITY ] [INTO] table [ (column, ...) ] VALUES ( values )

[, ( values )... ]

INSERT [LOW_PRIORITY] [INTO] table [ (column, ...) ] SELECT ...

INSERT [LOW_PRIORITY] [INTO] table SET column=value, column=value,...

뢠 ⠡. ਠ ⠢ 㪠 祭 㪠 ⮫. , 祭 ।, 祭 㬮砭 NULL. ன ਠ ⠢ ⠡ १ SELECT. ⨩ ਠ  ୠ⨢ ମ ࢮ,  㪠 ⮣, , 祭 ਤ. ᫨ INSERT ࢮ ᠭ ᯥ䨪஬ DELAYED, 室騥 SELECT ਮ । ஬ INSERT, 㤥 砭 ⢨ । . ࠧ ᯮ짮 ᯥ䨪 LOW_PRIORITY  INSERT ਢ ⮬, ᥩ 㤥 ⫮ 砭 㣨 権 .



ਬ ࠦ ORDER BY ᮬ SELECT, ᯮ㥬 INSERT. ⠡, ⢫ 롮ઠ. 稭 ᨨ 3.22.5 MySQL ⠢ ⠡ ࠧ. ⥬ ⥫쭮 ᯨ᪠ 祭, ࠧ 묨.

ࠢ INSERT ᯮ짮 ⮣ .



# ⠢ ⠡ 'people'

INSERT INTO people ( name, rank, serial_number )

VALUES ( 'Bob Smith', 'Captain', 12345 );

# ஢ , । , ⠡

# 'data' ⠡ 'old_data'. 筮 ⨬ ᫥ 㤠

# ᥩ 'data'.

INSERT INTO old_data ( id, date, field ) SELECT ( id, date, field) FROM data WHERE date < 87459300;

# ⠢ ⠡ 'people'.

INSERT INTO people (name, rank, serial_number ) VALUES ( 'Tim OVReilly', 'General', 1), ('Andy Oram', 'Major', 4342), ('Randy Yarger', 'Private', 9943);

KILL

KILL thread_id

蠥 㪠 ⮪. ID ⮪ ᭨ SHOW PROCESSES . 襭 ⮪, ਭ , 㣨 짮⥫, ॡ ࠢ process .



# ⮪ 3 KILL 3

LOAD

LOAD DATA [LOCAL] INFILE file [REPLACE|IGNORE] INTO TABLE table [delimiters] [(columns)]

⠥ ⥪⮢ 䠩 ⠢ ⠡. ⮤ ࠧ ॥, 祬 ᯮ짮 ஢ INSERT. 맢  , ⠫ SQL, ⠥, 㪠 । 䠩 室 ࢥ. ᫨ 䠩 㪠, MySQL ⮬ ⠫, ᯮ . ᨨ MySQL3.22, 稨 ᯥ䨪 LOCAL, 䠩 㤥 ⠭ 쭮 䠩 ⥬ ᪮ 設.

㪠 ࠧ⥫ (delimiters) LOAD DATA INFILE 㤥 , ⥪⮢ 䠩 ࠧ ᨬ ⠡樨, ᮡ ᨬ ࠭ १ (⠪ 뢠 - «\»), ப 稢 ᨬ ப.



㪠 ᮡ⢥ ࠧ⥫ ᫥ 祢 ᫮:

FIELDS TERMINATED BY ''

। ᨬ, ᯮ㥬 ࠧ . ⮡ 㪠 ᯥ樠 ᨬ, ᯮ짮 ⠭ ࠢ騥 몠 . 祭 ᮤঠ ᨬ. ਬ, FIELDS TERMINATED BY ', ' 砥 䠩, ࠧ 묨, a FIELDS TERMINATED BY '\t' 砥 ࠧ ⠡樥. ⠡樥  祭 㬮砭.

FIELDS ENCLOSED BY ''

। ᨬ ꥤ ᨬ쭮 ப. ਬ, FIELD ENCLOSED BY '' 㤥 , ப, ᮤঠ "this, value", "this", "value" , 㤥 ᠭ : "this,value", "this", "value". 㬮砭 ⠥, 䠩 ᯮ 窨.

FIELDS ESCAPED BY ''

। ᨬ, 㪠뢠騩 , ᨬ, ᫥騩 ,  , ᫨ 筮 ⠫ ࠢ騬. ਬ, FIELDS ESCAPED BY ' ਢ ⮬, ப "First, Second",Third, Fourth" 㤥 ⠭ : "First", "Second,Third" "Fourth" . ᪫祭  ᨬ . ਬ, ᫨ FIELDS ESCAPED BY 祭 ⭮ ᮩ , \0 㪠뢠 ASCII NULL (ᨬ ஬ 0), \N 㪠뢠 祭 null MySQL. ⭮ ᮩ  祭 㬮砭 ⮣ ࠬ. , MySQL ᬠਢ ᯥᨬ. ᫨ 室 ᯮ짮 ⮬ ࠦ, ᫥ ⤥ ⭮ ᮩ ⮩: FIELDS ESCAPED BY '\\' .

LINES TERMINATED BY 'C'

। ᨬ 㪠 砫 ப. 祭 ᪮쪮 ᨬ. ਬ, LINES TERMINATED BY '.', 䠩, 騩 , b, , d, e, f, g, h, k. , 㤥 ⠭ ⤥ , ६ ﬨ . 㬮砭 ᯮ ᨬ ப. 砥, 㬮砭 MySQL ⠥ ப ⤥쭮 .



祢 ᫮ FIELDS ᫥ ᯮ짮 ⮫쪮 ᥣ ࠦ. ਬ:

LOAD DATA INFILE data.txt FIELDS TERMINATED BY ','ESCAPED BY '\\'.

㬮砭, ᫨ ⠭ 䠩 祭 ᮢ 㦥 騬  ⮬ 㭨쭮 , 㤥 뤠 訡. ᫨ ࠦ 祢 ᫮ REPLACE, 祭 䠩 饥 ⠡. 祢 ᫮ IGNORE ਢ ஢ 祭 ࠭ ண.

䠩 ᫮ NULL ⠥ 㪠 ⮥ 祭, ᫨ ⮫쪮 뤥 ᨬ, 㪠묨

FIELDS ENCLOSED BY .

ᯮ짮 ᨬ ࠧ ࠧ⥫ MySQL. ਬ, FIELDS TERMINATED BY ',' ENCLOSED BY ', ' ਢ ।᪠㥬 .

᫨ ᯨ᮪ ⮫殢, ᠭ . ᫨ ⮫ 㪠, ᫮ 䠩 묨 ᮢ ᫮ ⠡, ⮬ 浪, ⠡.

믮 ⮣ ࠢ SELECT INSERT.



# 㧨 䠩 'mydata.txt' ⠡ 'mydata'. ⠥,

# ⤥ ⠡樥 祭 窨.

LOAD DATA INFILE 'mydata.txf INTO TABLE mydata

#㧨 'newdata.txt'. 뤥 묨

# ⠢

# 祭 'field"!' 'field2' ⠡ 'newtable'.

LOAD DATA INFILE 'newdata.txt' INTO TABLE newtable FIELDS TERMINATED BY

( field"!, -field2 )

LOCK

LOCK TABLES name [AS alias] READ|WRITE [, name2 [AS alias] READ|WRITE, ...]

⠡ ᯮ짮 ⤥ ⮪. ᭮ ᯮ 樨 ࠭権, ᠭ 7 «㣨 । ⠡». ᫨ ⮪ ᮧ ஢ READ, ⠫ ⮪ ⠡, 뢠 ⠡ ⮫쪮 , ஫騩 ⮪. ᮧ ஢ WRITE ⠫ ⮪ , ⠡.



६ ᯮ짮 ஢ ஢ ⠡ ਢ ᠭ ⮪. ஢ ⠡, ⢫ ६ ஢. ⮣ ॡ ⠡, ந室 ⮫쪮 ᫥ ஢. ᫥ ᨨ MySQL 뤠 訡 ⪥ 㯠 ஢ ⠡, ᫨ ६ 㣨, ஢ ⠡.



# ஢ ⠡ 'table1' 'table3'. ஢

#  ⠡

# 'table2'. ⠡ 'table3'ᮧ ᥢ 't3' ⥪饣

# ⮪.

LOCK TABLES table1 READ, table2 WRITE, tables AS t3 READ

OPTIMIZE

OPTIMIZE TABLE name

⠡, 㤠  ᯮ㥬 ࠭⢮. ⨬㥬 ⠡ ᮧ ⤥쭠 ६ ⠡, ⥬ 頥 ⥪饩 ⠡. ⠡ 樨 ६ ந室 筮 (ᨬ 뢠 ६ ⠡).



OPTIMIZE TABLE mytable

REPLACE

REPLACE INTO table [(column, ...)] VALUES (value, ....)

REPLACE INTO table [(column, ...)] SELECT select_clause

⠡, ⮬ , 뢠騥 䫨. 祭 INSERT ᪫祭 ⮣, 䫨 祭 騬 㭨 箬 祭 㤥 ᠭ ண. ਠ ⠢ 㪠 祭 㪠 . , 祭 ।, 祭 㬮砭 NULL. ன ਠ ⠢ ⠡ , 祭 १ SELECT.



# ⠢ ⠡ 'people'.

REPLACE INTO people ( name, rank, senal_number ) VALUES ( 'Bob Smith', 'Captain', 12345 )

# ஢ , । ,

# ⠡ 'data' ⠡ 'old_data'. 筮 ⨬ ᫥ 㤠

# ᥩ 'data'

REPLACE INTO old_data ( id, date, field )



SELECT ( id, date, field) FROM data WHERE date < 87459300

REVOKE

REVOKE privilege [(column, ...)] [, privilege [(column, ...) ,..] ON table FROM user

뢠 ࠢ 짮⥫. 祭 privilege, table user , GRANT. ࠢ GRANT 믮 ⮣ .

SELECT

SELECT [STRAIGHTJOIN] [DISTINCT|ALL] value[, value2...]

[INTO OUTFILE 'filename' delimiters] FROM table[, table2...] [clause]

롨ࠥ ⠡. SELECT  ᭮ ⮤ ⥭ ⠡ .

᫨ 㪠 ᪮쪮 ⠡, MySQL ⮬᪨ ꥤ ⠡ ⠪ ࠧ, ᬮ ࠢ 祭 . 砥 ᫨ MySQL 筮 䥪⨢ 믮 ᮥ, 㪠 । (祢 ᫮) STRAIGHT_JOIN ⠢ ࢥ ꥤ ⠡ 浪, . ᫨ 㪠 祢 ᫮ DISTINCT, 㤥 ⮫쪮 㯯 ᥩ 頥 . 祢 ᫮ ALL, ⨢, 뤠 饭 . 㬮砭 ALL.

頥 祭 ᫥饣 :

Aliases

᫮ ⮫殢 㭪権 , ᮧ ᥢ (alias). SELECT 祭 ᥣ ᥢ  . (ਬ, SELECT DATE_FORMAT(date, "%W, %M %d %Y") as nice_date FROM calendar .)

Column names

⮫殢 । column, table.column database, table.column . 室 ⮫쪮 ⮣, ⮡ ⫨ ⮫ 묨 , ᯮ짮  ६ (ਬ, SELECT name FROM people; SELECT mydata.people.name FROM people ).

Functions

MySQL । 롮 ஥ 㭪権 (. ). ᥣ CREATE FUNCTION 짮⥫᪨ 㭪樨 (ਬ, SELECT COS(angle) FROM triangle).

㬮砭 MySQL 頥 १ 짮⥫, ᤥ襬 . ७ࠢ १⮢ 䠩. ࠧ, ᮤন ⠡ ( ࠭ ) 䠩, 㤥 ⠭ 祫 ଠ஢ 㧪 .



䨪 INTO OUTFILE 'filename' delimiters 믮 ७ࠢ. 稨 १ SELECT 㤥 饭 䠩, 㪠 filename. ଠ ⮣ 䠩 । 㬥⠬ delimiters , ࠪ᪨ , LOAD DATA INFILE , ᫥騬 ﬨ:

ᯥ䨪 FIELDS ENCLOSED BY 祢 ᫮ OPTIONALLY . MySQL 㤥 ⮬ 砥 , , 祭 窨 ( 㣨 㪠 ᨬ),  ப, 稥 ਬ ᫮.

ࠧ⥫ (. . FIELDS TERMINATED BY ENCLOSED BY ' ' ) ਢ ᯮ짮 ଠ 䨪஢ ਭ. ᯮ஢ ᮮ⢥⢨ ࠭묨 ࠧࠬ . ଠ ⮫ ஭ ⠡.

㬮砭 ᯮ ࠧ⥫ 㤥 ᥭ ப, ᯮ짮 ࠧ ⠡樥 ᨬ ⭮ ᮩ (\) ⢥ ࠭饣 ᨬ.

᮪ ᯮ㥬 ⠡ 㪠 ᫥騬 ᯮᮡ:

Table1, bl2, bl3, . . .

ᠬ ⮩ ⮤. ᮥ ⠪, MySQL 䥪⨢. ᯮᮡ ⠪ ᠭ : Table1 JOIN Table2 JOIN bl3..... , ᯮ짮 祢 ᫮ CROSS, 䥪 (ਬ, Table1 CROSS JOIN Table2 ). ꥤ ⠡ ⮫쪮 , ⢥ ᫮ ⮫殢. ਬ, SELECT * FROM people, homes WHERE people. id=homes. owner ᮧ ꥤ ⠡, ᮤঠ ⠡ people , 祭 id ᮢ owner ⠡ homes.

祭, ⠡ ⮦ ᥢ (ਬ, SELECT tl.name, t2. address FROM long_table_name t1, longer_table_name t2).

Tablel STRAIGHT_JOIN Table2

筮 ࢮ ⮤, ᪫祭 ⮣, ⠡ ᫥ ᥣ ⠥ ࠭ ⠡ ࠢ. ⮤ ᫥ -



짮 砥, ᫨ MySQL 믮 ஢ 䥪⨢, ᮥ ⠡ ࠢ쭮 浪.

Table 1 LEFT [OUTER] JOIN Table2 N clause

ࠢ ࠢ ⠡ ࠦ. ᮮ⢥饩 ᮥ ⠡楩 㤥 ᯮ짮 , 祭 NULL. ।饬 ਬ SELECT * FROM people, homes LEFT JOIN people, homes ON people. id=homes. owner ꥤ ⠡ ᮤঠ , ᮢ騥 ⠡, ⠪ ⠡ people, ᮮ⢥⢨ ⠡ homes; ᮮ⢥ ⠡ homes ᯮ짮 祭 NULL. 祢 ᫮ OUTER 易⥫쭮 䥪.

Tablel LEFT [OUTER] JOIN Table2 USING (column[, column2. . . ])

ꥤ 㪠 ⮫, ⮫쪮 ᫨ ⠡ (ਬ, SELECT * FROM old LEFT OUTER JOIN new USING (id) ).

Tablel NATURAL LEFT [OUTER] JOIN Table2

ꥤ ⮫쪮 ⮫, ⠡. 䥪 ᯮ짮 ।饣 ᯮᮡ 㪠 ⮫殢, ⮩ 㣮 ⠡. (ਬ, SELECT rich_people.salary, poor_people.salary FROM rich_people NATURAL LEFT JOIN poorjeople .)

{oj Tablel LEFT OUTER JOIN Table2 ON clause }

ࠦ Table 1 LEFT JOIN Table2 ON clause, ন ⮫쪮 ᮢ⨬ ODBC («oj» «Outer Join»).

᫨ ࠦ , SELECT ୥ ࠭ ⠡ (⠡).

। ⡮ ᮤঠ ᫥ ࠧ:

WHERE statement

WHERE - ᠬ ᯮᮡ 롮ન SQL. 筮 ࠧ  ࠢ - ⨯, ⠪ ᮤঠ 㪠 㭪権, ஬ ॣ. ᯮ짮 , ⠪ ⮫殢 ᥢ, ᫮ ⠭ ப. ন ᫥騥 :

()

ᯮ 㯯஢ ஢, ⮡ 㪠 設⢮.



+

᫮ 祭.

-

⠭ ᫮ 祭. *

᫮ 祭.

/

᫮ 祭.

%

뤠 ᫮ 祭 (। ⪠).

⢫ ⮢ (OR) 楫᫥ 祭.

&

⢫ ⮢ (AND) 楫᫥ 祭.

<<

⢫ ⮢ ᤢ 楫᫥ 祭.

>>

⢫ ⮢ ࠢ ᤢ 楫᫥ 祭.

NOT !

믮 ᪮ (頥 1, ᫨ 祭 뫮 0, ).

OR ||

믮 ᪮ (頥 1, ᫨  -鮢 ࠢ 0, 頥 1).

AND &&

믮 ᪮ (୥ 0, ᫨ 㬥⮢ ࠢ 0, ୥ 1).

=

롨ࠥ , ᫨ 祭 ᮢ. ࠢ MySQL ⮬᪨ ந ८ࠧ ⨯.

<> !=

롨ࠥ , ᫨ 祭 ᮢ.

<=

롨ࠥ , 祭 ᫥ ࠭ ࠢ ࠢ.

<

롨ࠥ , ᫨ 祭 ࠢ.

>=

롨ࠥ , 祭 ᫥ ࠭ ࠢ ࠢ.

>

롨ࠥ , 祭 ᫥ ࠭ ࠢ.

value BETWEEN value1 AND value2

롨ࠥ , ᫨ value 室 valuel value2 ࠢ .

value IN (valuel,value2,... )

롨ࠥ , ᫨ value 室 । 㪠 祭.

value NOT IN (value1, value2,.., )

롨ࠥ , ᫨ value 室 । 㪠 祭.

valuel LIKE value2

ࠢ value1 value2 롨ࠥ , ᮢ. 祭 ࠢ ᮤঠ ⠭ ' %', ஬ 㤮⢮  ᫮ ᨬ ( 0) '_', 騩 ஢ ᨬ. , , ᠬ 㯮ॡ⥫쭮 SQL ࠢ. ᥣ ᯮ ࠢ ᨬ ⠭ (ਬ, SELECT name FROM people WHERE name LIKE 'B%' ).



valuel NOT LIKE value2

ࠢ valuel value2 롨ࠥ , ᮢ. 筠 NOT (valuel LIKE value2).

valuel REGEXP/RLIKE value2

ࠢ valuel value2, ᯮ ७ ᨭ⠪ ॣ ࠦ, 롨ࠥ , ᫨ ᮢ. 祭 ࠢ ᮤঠ ⠭ ࠦ 樨 Unix (ਬ, SELECT name FROM people WHERE name RLIKE '^B. *').

valuel NOT REGEXP value2

ࠢ valuel value2, ᯮ ७ ᨭ⠪ ॣ ࠦ, 롨ࠥ , ᫨ ᮢ. 筠 NOT (valuel REXEXP value2).

। WHERE ୥ 祭 ࠦ 祭, ⫨ 0 NULL (. . ,  ᪨ ). ⮬ SELECT age FROM people WHERE age>10 ୥ ⮫쪮 , 10.

GROUP BY column[, column2,...]

㯯 祭 । ⮫, 믮 ॣ 㭪樨 ⮫栬 columns (ਬ, SELECT name, MAX(age) FROM people GROUP BY name ).

HAVING clause

ࠦ WHERE, 믮 㦥 祭묨 묨. HAVING 믮 ॣ 㭪樨 ⭮⥫쭮 訬 ࠬ , -㦥 ࠭묨 ⠡. ⮬ 砥 㤥 ࠡ 楫 ⠡楩, ⮫쪮 ࠭묨 묨 (ਬ, SELECT name, MAX(age) FROM people GROUP BY name HAVING MAX(age)>80 ).

ORDER BY column [ASC |DESC][, column2 [ASC |DESC], . . . ]

頥 ⮫ ( ⮫栬). ᫨ 㪠 DESC, ஢ 뢠, ਬ ஢ ⠭. ஢ ⠭  ࠧ, 㪠 ASC (ਬ,

SELECT name, age FROM people ORDER BY age DESC ).

LIMIT [ start, ] rows

頥 ⮫쪮 㪠 ⢮ ᥩ. 祭 start (易⥫쭮) । ⢮ ᥩ, ய । 롮મ . 㬥 ᥩ 稭 . (ਬ, SELECT url FROM links LIMIT 5,10 頥 URL 5 14.)



PROCEDURE name

mSQL ࠭ MySQL 祣 믮. ন 祭 㣨 SQL-ࢥ஢. 稭 ᨨ MySQL 3.22 ࠧ 㪠 楤, १ । ⮬ .

SELECT ন 楯 㭪権. MySQL ஥ 㭪権, ᯮᮡ ஢ 묨 ⠡, 짮⥫ 塞 祭. 㭪権 祭 ᫮ ப, ᨬ ⮣, ଠ 室 짮⥫. 뢠 «⥪⮬» 㭪樨. ࠭ 祭 뢮 ᯫ, ᯮ ⮫쪮 ⥪⮢ ⥪, ࠭ ⠡ ᯮ짮 ⢥ 㬥⮢ 㣨 㭪権 ⥪ ⮣, ⥫ . ⭮, ࠭ ᫥饣 ᫮ ⨯, ⥪ 㭪樨 㤥 ᫮.

ਢ ஥ MySQL 㭪樨:

ABS(number)

頥 ᮫⭮ 祭 ᫠ number (ਬ, ABS (-10) 頥 10).

COS(number)

頥 પᨭ ᫠ number ࠤ (ਬ, ACOS (0) 頥 1.570796).

ASCII(char)

頥 ASCII ᨬ (ਬ, ASCII (' h') ୥ 104).

ASIN(number)

頥 ᨭ ᫠ number ࠤ (ਬ, ASIN (0) ୥ 0.000000).

ATAN(number)

頥 ⠭ ᫠ number ࠤ (ਬ, ATAN (1) ୥ 0.785398).

ATAN2(X, Y)

頥 ⠭ 窨 (X, Y) (ਬ, ATAN (-3,3) 頥-0.785398).

HAR(num1[,num2,. . .])

頥 ப, 祭 १ ८ࠧ ᥫ , ᮮ⢥騩 ᫮ ASCII (ਬ, CHAR (122) 頥'z').

CONCAT(string 1, string2 [, strings,. . . ])

頥 ப, ନ஢ ᮥ 㬥⮢ (⥭) (ਬ, CONCAT('Hi',' ','Mom','!') ୥ «Hi Mom!»).



CONV( number, basel, base2 )

頥 祭 ᫠ number, ॢ ⥬ ᫥ basel base2. ᫮ 楫᫥ ( ᮡ⢥ ᫮ ப). ⥬ ᫥ 楫 ᫮ 2 36 (ਬ, CONV (8,10,2) 頥 1000 (᫮ 8 筮 ⥬, ਢ 筮 )).

BIN( decimal)

頥 筮 祭 㪠 筮 ᫠ decimal. 㭪樨 CONV (decimal, 10,2) (ਬ, BIN(8) ୥ 1000).

BIT_COUNT( number)

頥 ᫮ ⮢, ⠭ 1 筮 ।⠢ ᫠ (ਬ, BIT_COUNT (17) 頥 2).

CEILING( number)

頥 襥 楫 ᫮, ஥ ࠢ 㪠 number (ਬ, CEILING (5.67) 6).

COS( radians )

頥 ᨭ ࠤ ᫠ number (ਬ, COS(O) ୥ 1. 000000).

( radians)

頥 ⠭ ᫠ number, ࠤ (ਬ, (1) ୥ 0.642093).

CURDATE()/CURRENT_DATE()

頥 ⥪ . ᯮ짮 ᫮ ⥪ 頥 ᫮ YYYYMMDD , ୥ ப 'YYYY-MM-DD' (ਬ, CURDATE() «1998-08-24»).

CURTIME()/CURRENT_TIME()

頥 ⥪饥 ६. ᯮ짮 ᫮ ⥪ 頥 ᫮ HHMMSS, 頥 ப : : SS (ਬ, CURRENT_TIME() 13:02:43).

DATABASE()

頥 ⥪饩 (ਬ, DATABASE() «mydata»).

DATE_ADD(date, INTERVAL amount type )/ADDOATE(date, INTERVAL amount type )

頥 , ନ஢ ⢠ ६ 㪠 . 塞 ६ ।⠢ ᫥ ⨯: SECOND, MINUTE, HOUR, DAY, MONTH, YEAR, MINUTE_SECOND ( «ᥪ㭤»), HOUR_MINUTE ( «:»), DAY_HOUR ( « »), YEAR_MONTH ( «-»), HOUR_SECOND ( «::ᥪ㭤»), DAY_MINUTE ( « :») DAY_SECOND ( « ::ᥪ㭤»). ᪫祭 㪠 ⨯, amount 楫 祭. (ਬ, DATE_ADD("1998-08-24 13:00:00", INTERVAL 2 MONTH) ୥ «1998-10-24 13:00:00».)



DATE_FORMAT( date, format )

頥 㪠 ଠ. ப ଠ ⠥ ⮬ , , 믮 ᫥ ⠭:

%

饭 (Sun, Mon . .).

%b

饭 (Jan, Feb . .).

%D

浪 ᮬ (1-, 2-, 3- . .).

%d

.

%

24-ᮢ (ᥣ , ਬ 01).

%h/%I

12-ᮢ (ᥣ , ਬ 09).

%i

.

%j

.

%k

24-ᮢ ( , ਬ 1).

%1

12-ᮢ ( , ਬ 9).

%

.

%m

(1 - ﭢ).

%

AM .

%r

12-ᮢ ६ ( /).

%S

㭤 (ᥣ , ਬ 04).

%s

㭤 ( , ਬ 4).

%

24-ᮢ ६.

%U

( 稭 ᥭ).

%W

.

%w

(0 - ᥭ).

%Y

姭 .

%

, .

%%

« % ».

DATE_SUB( date, INTERVAL amount type )/SUBDATE( date, INTERVAL amount type )

頥 , ନ஢ ⠭ 㪠 ⢠ ६ 㪠 . ᯮ ᠬ ⨯, DATE_ADD (ਬ, SUBDATE(" 1999-05-20 11:04:23", INTERVAL 2 DAY) 頥 «1999-05-18 11:04:23»).

DAYNAME( date,)

頥 㪠 (ਬ,

DAYNAME(' 1998-08-22')

頥 «Saturday»).

DAYOFMONTH( date)

頥 祭 㪠 (ਬ, DAYOFMONTHC1998-08-22') 頥 22).

DAYOFWEEK( ctete)/WEEKDAY( date)

頥 (1 - ᥭ) 㪠 (ਬ, DAY_ OF_WEEK('1998-08-22') 頥 7).

DAYOFYEAR( date)

頥 㪠 (ਬ, DAYOFYEAR ('1983-02-15') 頥 46).

DEGREES( radians )

頥 㬥, ஢ ࠤ ࠤ (ਬ, DEGREES(2 *PI()) 頥 360.000000).



ELT(number, string1, string2, . . . )

頥 string?, ᫨ number ࠢ 1, string2, ᫨ number ࠢ 2, . . ᫨ ᫮ number ᮮ⢥ ப, 頥 NULL (ਬ, ELT(3, "once", "twice", "thrice", "fourth") 頥 «thrice»).

ENCRYPT( string[, salt])

, ⠢ ஫ ப. ᫨ 㪠 ஢ salt, ᯮ 樨 ஫ (ਬ, ENCRYPT('mypass', '') «3afi4004idgv»).

(power)

頥 ᫮ , 㪠 ⥯ (ਬ, (1) 頥 2.718282).

FIELD( string, string1, string2, . . . )

頥 㬥 (稭 stringl) ᯨ᪥ 㬥⮢, ᮢ string. ୥ 0, ᫨ ᮢ (ਬ, FIELD( 'abe', '', 'John', 'abe', 'bill') 頥 3).

FINO_IN_SET( string, set)

頥 string set. 㬥 set - ப, ࠧ 묨 (ਬ, FIND_IN_SET ('abe', ', John, abe, bill') 頥 3).

FLOOR( number)

頥 襥 楫 ᫮, ஥ ࠢ number (ਬ, FLOOR (5.67) 頥 5).

FORMAT( number, decimals )

⭮ ଠ ᫮, ᯮ ஡ (ਬ, FORMAT(4432.99134,2) 頥 «4,432.99»).

FROM_DAYS( days)

頥 , ᫮ ( 1 - ࢮ ﭢ ࢮ ) (ਬ, FROM_DAYS(728749) ୥ «1995-04-02»).

FROM_UNIXTIME( seconds [, format])

頥 (GMT), ᮮ⢥ 㪠 ᥪ㭤, 襤 砫 (1- ﭢ 1970 . GMT). ᫨ । ଠ ( ᯮ짮 ࠬ஢, DATE_FORMAT ), 頥 ६ ଠ ᮮ⢥騬 ࠧ (ਬ, FROM_UNIXTIME(903981584) 頥 «1998-08-24 18:00:02»)-

GET_LOCK( name, seconds )

।塞 짮⥫ ஢, ⢮ ᥪ㭤 ⠩. ᯮ짮 ᪮ ਫ 믮 ஢ ணࠬ, ᯮ ஢. ᫨ ஢ 諠 ᯥ譮, 頥 1. ᫨ ६ ⥪, ୥ 0. ⠫ 訡 ୥ 祭 NULL. ⮫쪮 ⨢ ஢ ᨨ. GET_LOCK() 㤠 । ஢ ।० (ਬ, GET_ LOCK("mylock", 10) 1 祭 10 ᥪ㭤).



GREATEST (num 1, num2[, num, . . . ])

頥 訩 㬥⮢ (ਬ, GREATEST(5, 6, 68,1,4) 頥 68).

(decimal )

頥 ⭠筮 祭 㪠 筮 ᫠. 㭪樨 CONV(decimal, 10,16) (ਬ, (90) 頥 «»).

HOUR(time)

頥 㪠 (ਬ, HOUR('15:33:30') 頥 15).

IF(test, value1, value2 )

᫨ test ⨭, 頥 valuel, 頥 value2. 祭 test 楫᫥, ⮬ ᫠ 饩 ⮩ ᫥ ᯮ짮 ᫥ ८ࠧ ⨯ integer (ਬ, IF(1>0, "true", "false") 頥 true).

IFNULL( value, value2 )

頥 value, ᫨ ࠢ null, 頥 value2 (ਬ, IFNULL(NULL, "bar") 頥 «bar»).

INSERT( string, position, length, new )

頥 ப, ᮧ ⥬ ᨬ ப string ᨬ new. 㤥 ⢮ ᨬ, 㪠 length, 稭 樨 position (ਬ, INSERT( 'help', 3,1, ' can jum') 頥 «he can jump»).

INSTR( string, substring )

筮 㭪樨 LOCATE, ᪫祭 ⮣, .㬥 ⭮ 浪 (ਬ, INSTR( 'makebelieve', 'lie') 頥 7).

ISNULL( expression )

頥 1, ᫨ ࠦ expression ࠢ NULL, 頥 0 (ਬ, ISNULL(3) ୥ 0).

INTERVAL( , , , D, . . . )

頥 0, ᫨ - 襥 祭, 1 - ᫨ 室 , 2- ᫨ 室 D, . . 祭, ஬ , 浪 (ਬ, INTERVAL (5,2,4,6,8) 頥 2 (⠪ 5 室 ஬ ࢠ 4 6).

LAST_INSERT_ID()

頥 ᫥ 祭 AUTO_INCREMENT , ஥ 뫮 ᮧ ⮬᪨ (ਬ, LAST_INSERT_ID() 4).

LCASE( string )/LOWER( string)

頥 ப string, ᨬ ॢ ॣ (ਬ, LCASE(' ') 頥 «bob»).



LEAST(num1, num2[, num3, . . . ])

頥 訩 㬥⮢ (ਬ, LEAST(5,6,68,1,4) 頥 1).

LEFT( string, length )

頥 ⢮ ᨬ length ப string, 稭 砫 ப (ਬ, LEFTC 12345", 3) 頥 «123»).

LENGTH (string)/OCTET_LENGTH( string )/CHAR_LENGTH( string)/ CHARACTER_LENGTH( string)

頥 ப string (ਬ, CHAR_LENGTH( 'Hi Mom! ' ) 頥 7). ᨬ ᨬ (ਬ, Unicode ᪨ ᨬ). ப 㭪樨 MySQL ࠢ쭮 ᫮ ᨬ, ⮢. 3.23 㭪 ࠡ⠫ 頫 ᫮ .

LOCATE( substring, string [, number ])/POSITION( substring, string )

頥 ப substring ப string. 頥 0, ᫨ substring . ᫨ LOCATE ⨩ ᫮ 㬥, ப 筥 ⮫쪮 樨, 㪠 ⨬ 㬥⮬ (ਬ, LOCATE(' SQL', ' MySQL') ୥ 3).

LOG(number)

頥 ࠫ ᫠ number (ਬ, LOG(2) 頥 0.693147).

LOG10(number)

頥 () ᫠ (ਬ, LOG10(1000) 頥 3.000000).

LPAD( string, length, padding )

頥 ப string padding 砫 ப. 㤥 , ப ⨣ , 㪠 length, (ਬ, LPAD(' -Merry X-Mas',18, '') 頥 « Merry X-Mas»).

LTRIM( string)

頥 ப string 㤠 砫 ஡ (ਬ, LTRIM(' Oops') 頥 «Oops»).

MID( string, position, length )/SUBSTRING( string, position, length )/

SUBSTRING( string FROM position FOR length )

頥 ப ⢠ ᨬ, 㪠 length, ப string, 稭 樨 position (ਬ, SUBSTRING(' 12345', 2,3) 頥 «234»).



MINUTE( time)

頥 ⢮ 㪠 ६ (ਬ, MI-NUTE('15:33:30') 頥 33).

OD(num1, 2)

頥 ᫠ 1, ᫮ 2. 㭪 筠 % (ਬ, MOD(11,3) 頥 2).

MONTH (date)

頥 (1 砥 ﭢ) 㪠 (ਬ, MONTH(' 1998-08-22') 頥 8).

MONTHNAME( date)

頥 㪠 (ਬ, MONTHNAME('1998-08- 22') 頥 «August»).

NOW()/SYSDATE()/CURRENT_TIMESTAMP()

頥 ⥪ ६. ᫮ ⥪ 頥 ᫮ YYYYMMDDHHMMSS , 砥 ୥ ப 'YYYY-MM-DD HH:MM:SS' (ਬ, SYSDATE() «1998-08-24 12:55:32»).

OCT( decimal)

頥 쬥筮 祭 筮 ᫠. 㭪 ⭠ 㭪樨 CONV(deciinal, 10,8) (ਬ, (8) 頥 10).

PASSWORD( string)

頥 ஢ ப. (ਬ, PASSWD( 'mypass') «3afi4004idgv».)

PERIOD_ADD( date, months )

頥 , ନ஢ ⥬ 㪠 ᫠ 楢 ( ଠ YYMM YYYYMM) (ਬ, PERIOD_ADD(9808,14) 頥 199910).

PERIOD_DIFF( date1, date2 )

頥 ⢮ 楢 㪠묨 ⠬ ( 㪠 ଠ YYMM YYYYMM) (ਬ, PERIOD_DIFF(199901,8901) ୥ 120).

PI()

頥 ᫮ : 3.141593.

POW(num1, num2)/POWER( num1, num2]

頥 祭 ᫠ 1, ⥯ 2- (ਬ, POWER(3,2) 頥 9.000000).

QUARTER( date)

頥 ⠫ 㪠 (1 - ﭢ-) (ਬ, QUARTER(' 1998-08-22') 頥 3).

RADIANS( degrees)

頥 祭 㬥, ॢ ࠤᮢ ࠤ (ਬ, RADIANS(-90) 頥 -1.570796).

RAND ([seed])

頥 砩 ஡ 0 1. ᫨ 㬥, ᯮ 筨 (seed) 砩 ᥫ (ਬ, RAND(3) 0.435434).



RELEASE_LOCK( name)

஢, ᮧ 㭪樥 GET_LOCK . ୥ 1, ᫨ ⨥ ஢ 뫮 ᯥ; 0, ᫨ ஢ 㤠 , ᪮ ਭ ⥪饬 ⮪; NULL, ᫨ ஢ (ਬ, RELEASE_LOCK("mylock") ).

REPEAT( string, number )

頥 ப, 祭 ⥬ ७ ப ஥ ᫮ ࠧ (㪠 number). ୥ ப, ᫨ number ࠢ (ਬ, REPEAT( 'ma', 4) 頥 'mamamama').

REPLACE( string, old, new )

頥 ப, ன 宦 ப old ப new (ਬ, REPLACE('black jack','ack1,'oke') 頥 «bloke joke»).

REVERSE( string)

頥 ᨬ ப string ⭮ 浪 (ਬ, REVERSE('my bologna') 頥 «angolobym»).

RIGHT( string, length )/SUBSTRING( string FROM length)

頥 ⢮ ᨬ string, 㪠 length, 稭 ப (ਬ, SUBSTRING( «12345» FROM 3) 頥 «345»).

ROUND( number [.decimal ])

㣫 ஡ ᫠ number 㪠 ⢠ . ᫨ 㬥 decimal 㪠, ᫮ 㣫 楫 (ਬ, ROUND(5.67,1) 頥 5.7).

RPAD( string, length, padding )

頥 ப string padding ப. 㤥 , ப ⨣ , 㪠 length (ਬ, RPAD( 'Yo', 5, '! ') 頥 «Yo!!!»).

RTRIM( string)

頥 ப string 㤠 楢 ஡ (ਬ, RTRIM( 'Oops ') ୥ «Oops»).

SECOND( time)

頥 ᥪ㭤 㪠 ६ (ਬ, SE-COND('15:33:30') 頥 30).

SEC_TO_TIME( seconds )

頥 ᫮ ᮢ, ᥪ㭤 ⢥ ᥪ㭤. ᯮ짮 ᫮ ⥪ 頥 ᫮ ଠ HHMMSS, ୥ ப HH:MM:SS (ਬ, SEC_TO_TIME(3666) 頥 «01:01:06»).



SING( number)

頥 -1, ᫨ ᫮ number ⥫쭮, 0, ᫨ , 1, ᫨ ⥫쭮 (ਬ, SIGN(4) 頥 1).

SIN( radians)

頥 ᨭ ᫠, ࠤ (ਬ, SIN(2*I()) 頥0. 000000).

SOUNDEX(stdng)

頥 Soundex, 易 ப (ਬ, SOUNDEX(' Jello') 頥 «J400»).

SPACE(number)

頥 ப ஡, ᫮ 㪠 number (ਬ, SPACE( 5) 頥<>).

SQRT(number)

頥 ७ ᫠ number (ਬ, SQRT(16) 頥 4.000000).

STRCMP( string1, string2 )

頥 0, ᫨ ப ᮢ, -1 ᫨ string1 ஢ ࠭ ப string2; 1, ᫨ string! 뫠 ஢ ᫥ string2 (ਬ, STRCMP( 'bob', 'bobbie') 頥 -1).

SUBSTRING_INDEX( string, character, number )

⠥ ⢮ 㪠 ᨬ character ப string , ⠥ ᫠ number. ᫨ ᫮ 뫮 ⥫, ୥ , ᫥ ᨬ, ஬ ⠭ 稪, ᫨ ᫮ ⥫쭮, 㭪 ୥ , 室 ࠢ . (ਬ, SUBSTRINGJENDEXC 1,2, 3,4,5', ',',-3) 頥 «1,2,3».)

SUBSTRING( string,position )

頥 ப string, 稭 ᨬ 㪠 position (ਬ, SUBSTRING(«123456», 3) 頥 «3456»).

TAN(radians )

頥 ⠭ ᫠, ࠤ (ਬ, TAN(0) 頥 0.000000).

TIME_FORMAT( time, format)

ଠ ६ 㪠 ଠ. ଠ , DATE FORMAT , ᠭ .

TIME_TO_SEC( time)

頥 ⢮ ᥪ㭤 㬥 time (ਬ, I__ 8(' 01:01:06') 頥 3666).

TO_DAYS(date)

頥 ⢮ , 襤襥 㪠 ( 1 - 1- ﭢ 1- ). 祭 ⨯ DATE, DATETIME, TIMESTAMP ᫮ ଠ YYMMDD YYYYMMDD (ਬ, TO_DAYS( 19950402) 頥 728749).



TRIM([BOTH|LEADING|TRAILING] [ remove ] [FROM] string)

頥 ப string 㤠묨 楢묨 砫묨 ஡. 㪠, ஡ 㤠 (楢, 砫 㣨). ஡ 㪠 㣮 ᨬ (ਬ, TRIM( both ' ' from ' --look here-') 頥 «look here»).

TRUNCATE( number, decimals )

頥 number ஡ , 祭 㪠 ⢠ . (ਬ, TRUNCATE(3.33333333,2) 頥 3.33.)

UCASE( string)/UPPER( string)

頥 string, ᨬ ॢ 孨 ॣ (ਬ, UPPER ('Scooby') 頥 «SCOOBY»).

UNIX_TIMESTAMP([ date])

頥 ᫮ ᥪ㭤, 襤襥 砫 (1 ﭢ 1970 . GMT) (GMT). ᫨ 㪠, 頥 ᫮ ᥪ㭤, 襤襥 ⥪饩 (ਬ, UNIX_TI-MESTAMPC1998-08-24 18:00:02') 頥 903981584).

USER()/SYSTEM_USER()/SESSION_USER()

頥 ⥪饣 짮⥫ (ਬ, SYSTEM_USER() «ryarger»).

VERSION()

頥 ᠬ ࢥ MySQL (ਬ, VERSION() «3.22. 5c-alpha»).

WEEK(date)

頥 浪 㪠 (ਬ, WEEK( '1998-12-29') 頥 52).

YEAR (date)

頥 㪠 (ਬ, YEAR('1998-12-29') 頥 1998).

ॣ 㭪樨, 믮塞 ஬ . 筮 ⮤ ᯮ 믮 ண ⢨ ᥬ ஬ 頥 . ਬ, 㭪 SELECT

AVG(height) FROM kids 頫 । 祭 ' height' ⠡ kids.

AVG( expression )

頥 । 祭 祭 expression (ਬ, SELECT AVG(score) FROM tests ).

BIT_AND( expression )

頥 १ ⮢ , ॣ饣 祭 expression (ਬ, SELECT BIT_AND(flags) FROM options ).

BIT_OR( expression )



頥 ⮢ , ॣ饥 祭 祭 expression (ਬ, SELECT BIT_ OR(flags) FROM options ).

COUNT( expression )

頥 ⢮ ࠧ, 祭 expression 뫮 㫥. COUNT(*) ୥ ᫮ ᥩ - 묨 ᥩ ⠡ (ਬ, SELECT COUNT( *) FROM folders ).

MAX( expression )

頥 襥 祭 expression (ਬ, SELECT MAX (elevation) FROM mountains ).

MIN( expression )

頥 襥 祭 expression (ਬ, SELECT MIN(level) FROM toxic_waste ).

STD( expression )/STDDEV( expression )

頥 ।筮 ⪫ 祭 expression (ਬ, SELECT STDDEV(points) FROM data ).

SUM(expression )

頥 㬬 祭 expression (ਬ, SELECT SUM(calories) FROM daily_diet ).



# () ⠡ 'people', 'state'

# ࠢ 'Ml'.

SELECT name FROM people WHERE state-'MI'

# ⠡ 'mytable'. SELECT * FROM mytaPle

SET

SET OPTION SQL_OPTION=va.Zue

⠭ ன ⥪饩 ᨨ. । ⨬ ஬ ࠬ ⮫쪮 ⥪饣 ᮥ 祧 ⨨. 饥 ६ ন ᫥騥 ன:

CHARACTER SET charselname DEFAULT

ᨬ, ᯮ㥬 MySQL. ন ⮫쪮 ୠ⨢ ᨬ cp1251_koi8, ⭮ ᪮ . DEFAULT, ୥ ⠡ ᨬ.

LAST_INSERT_ID= number

⠭ 祭, 頥 㭪樥 LAST_INSERT_ID() .

SQL_BIG_SELECTS=0 1

। ॠ ⥬ 㦥 SELECT. ᫨ ⠭ 1, MySQL ࢥ , 뤠 訡 ।० ⮬, , , ॡ ᫨誮 ६ ࠡ. MySQL 蠥,  ᫨誮 , ᫨ ਤ ࠡ뢠 ᥩ, 祬 㪠 ⥬ ६ max_join_size . 㬮砭 祭 ࠢ 0, ࠧ蠥 .



SQL_BIG_TABLES=0 1

। ࠡ ६묨 ⠡栬 ( ᮧ묨 筮 ࠡ⪥ ஢ ). ᫨ 祭 ࠢ 1, ६ ⠡ ࠭ ᪥, 㤥 ࠡ ⨢ , । 訡 ⥬ 訬 ꥬ . 祭 㬮砭 -, ६ ⠡ ࠭ RAM.

SQL_LOG_OFF=0 1

⠭ ࠬ 1 몫砥 ⠭⭠ ୠ--⥪饩 ᨨ. ୠ ISAM ୠ 몫. ࠢ PROCESS LIST ᯮ짮 ⮩ ⠭. 㬮砭 祭 ࠢ 0, ࠧ蠥 ୠ. 4 «MySQL», ᠭ ࠧ 奬 ୠ樨 MySQL.

SQL_SELECT_LIMIT= number

ᨬ쭮 ⢮ ᥩ, 頥 ᮬ SELECT. 䨪 LIMIT ⬥ 祭. 㬮砭 .

SQL_UPDATE_LOG=0 1

몫砥 ୠ ⥪饩 ᨨ 祭, ࠢ 0. ⠭ ୠ ୠ ISAM. ࠢ

PROCESS LIST ᯮ짮 ⮩ ⠭. 㬮砭 祭 ࠢ 1, ࠧ蠥 ୠ.

TIMESTAMP= value DEFAULT

⠭ ६, ᯮ짮 ᨨ. ६ 뢠 ୠ ਬ ⠭ ୠ. ⠭ DEFAULT ୥ ⥬ ६.



# 몫 ୠ ⥪饩 ᨨ.

SET OPTION SQL_LOG_OFF=1

SHOW

SHOW DATABASES [LIKE clause]

SHOW KEYS FROM table [FROM database]

SHOW INDEX FROM table [FROM database]

SHOW TABLES [FROM database] [LIKE clause]

SHOW COLUMNS FROM table [FROM database] [LIKE clause]

SHOW FIELDS FROM table [FROM database] [LIKE clause]

SHOW STATUS

SHOW TABLE STATUS [FROM database] [LIKE clause]

SHOW VARIABLES [LIKE clause]

뢮 ࠧ ଠ ⥬ MySQL. ࠦ ᯮ짮 ᭥ ࠪ᪨  .





# 㯭 . SHOW DATABASES

# ଠ ⠡ 'bigdata'

SHOW KEYS FROM bigdata

# ଠ ⠡ 'bigdata' 'mydata'

SHOW INDEX FROM bigdata FROM mydata

# 㯭 ⠡ 'mydata', 稭騥

# 㪢 'z'

SHOW TABLES FROM mydata LIKE 'z%'

If 뤠 ଠ ⮫ ⠡ 'skates'

SHOW COLUMNS FROM stakes

# 뤠 ଠ ⮫ ⠡ 'people',

# 騬 '_name'

SHOW FIELDS FROM people LIKE '%\_name'

# ଠ ﭨ ࢥ SHOW STATUS

# ⥬ ६ SHOW VARIABLES

UNLOCK

UNLOCK TABLES

⠡ ⥪饬 ᮥ, ஢ ࠦ LOCK.



# Unlock all tables UNLOCK TABLES

UPDATE

UPDATE table SET column=value, . . . [WHERE clause]

⠡. ࠦ ᯮ 䨪樨 ᠬ ⠡. ᯮ짮 ⮫ 筨 祭 value ⠭ 祭. ਬ, UPDATE health SET miles_ran=miles_ran+5 5 ⥪饬 祭 miles_ran. 頥 ᫮ ᥩ.

믮 ࠦ 室 ࠢ UPDATE .



# 'John Deo' 'John Doe' ᥩ ⠡ 'people'.

UPDATE people SET name='John Doe' WHERE name='John Deo'

USE

USE database

롨ࠥ 㬮砭. ࠦ 㤥 ᯮ짮 㬮砭 ᫥ . 㣨  㪠 ⥬ 祭 database.table.column .



# db1 㬮砭 USE db1




mSQL


MySQL mSQL

MySQL mSQL . , , .



mSQL


mSQL 2 . mSQL 2.0 , mSQL . , mSQL 2.


mSQL. .

MSQL_DEBUG

. 0 ( ) 3 ( ).

MSQL_CONF_FILE

mSQL.

, mSQL , Unix:

USER

.

EDITOR

VISUAL

. msql SQL , \.

mSQL

mSQL , mSQL. /usr/local/Hughes/msql.conf. MSQL_CONF_FILE. , . msql.conf:

[general]

Inst_Dir = /usr/local/Hughes

mSQL_User = msql

Admin_User = root

Pid_File = %I/msql2d.pid

TCP_Port =1114

UNIX_Port = %I/msql2.sock

[system]

Msync_Timer = 30 Host_Lookup = True Read_0nly = False

[w3-msql]

Auth_Host = NULL Footer = True Force_Private = False

general mSQL, msqld system, w3-msql W3-mSQL, WWW. mSQL , %1 mSQL . .


general

Admin_User

, mSQL . root.

Inst_Dir

mSQL. , %1, . - /usr/local/Hughes.

mSQL_User

, mSQL. msql.

Pid_File

, ID (PID) mSQL. - %I/msql2d. pid.

TCP_Port

TCP-, , msql2d - , . - 1114.

UNIX_Port

Unix, mSQL ( ) ( msql2d). - %I/msql2. sock.

system

Host_Lookup

'True', .

Msync_timer

( ) , RAM, .

Read_Only

'True', . SELECT.

w3-msql

Auth_Host

, W3-Auth. NULL , .

Footer

'True', Hughes Technologies.

Force_Private

'True' W3-mSQL W3-Auth . HTML- W3-mSQL.


MySQL


MySQL

MySQL. . MySQL (mysqld), safe_mysqld MySQL ( ).

MY_BASEDIR

MY_BASEDIR_VERSION

, 'bin', 'var' 'libexec' MySQL. , ( MySQL /usr/local). mysqld.

MYSQL_DEBUG

( ). MySQL. MySQL . : http://www.turbolift.com/ sql/appendixC.html. - d: t: , / tmp/debugfile.

MYSQL_HOST

, MySQL. MySQL (mysql, mysqlshow, mysqladmin . .).

MYSQL_PWD

, MySQL. MySQL.

. . , MYSQL_PWD , . , .

MYSQL_TCP_PORT

TCP- , MySQL. mysqld, - TCP-, .


MYSQL_UNIX_PORT

- Unix, MySQL. mysqld - Unix .

, MySQL , Unix.

EDITOR VISUAL

. mysql SQL-, edit \.

HOME

. LOGIN LOGNAME USER

.

PATH

, .

POSIXLY_CORRECT

, . , . MySQL.

TMPDIR

, . , '/tmp '.

TZ

.

UMASK

, .



-0 -set-variable, MySQL.

back_log

TCP, . - 5. mysqld.

connect _timeout

( ), mysqld , (bad handshake).

decode-bits

, . 4 9 ( 4 6 16- ). - 9. isamchk. , ISAM.



delayed_insert_limit

INSERT DELAYED SELECT, , delayed _insert_limit. , .

delay ed_insert_timeout

INSERT DELAYED INSERT .

delayed_queue_size

( ) INSERT DELAYED. , , INSERT DECAYED, , .

dritebuffer

, . - 260 . isamchk.

flush_time

, flush_time , .

join_buffer

. , . 130 . mysqld.

key_buffer_size

, (), . , . isamchk ( 0.5 ) mysqld ( 1 ).

long_query_time

, slow_queries , , long_query_time ( ).

max_allowed_packet

, . . 64 . mysqld.

max_connect_errors

, , max_connect_errors. FLUSH HOSTS.



max_Connections

. - 90. mysqld.

max_delayed_threads

, INSERT DELAYED, . INSERT DATA , , DELAYED ?

max_join_size

, . - 4 . mysqld.

max_sort_length

, BLOB VARCHAR. 1 .

max_tmp_tables

( 3.23.) , .

net_buffer_length

. .

8 . mysql, mysqld mysqldump.

readbuffer

, . 260 . isamchk.

record_buffer

, , ( ). , (). 130 . mysqld.

sortbuffer

, . 1 . isamchk.

sort_buffer

, . , ORDER BY GROUP BY. 2 . mysqld.

sort_key_blocks

( ), . 16. isamchk, , ISAM.



table_cache

, . 64 . mysqld.

tmp_table_size

, . - 1 . mysqld.

thread_stack

. -64 . mysqld.

wait_timeout

, , .

MySQL

MySQL 3.22, , . , . /etc/my.cnf, MySQL . MySQL (, /usr/local/mysql/data/ my.cnf), MySQL. , .my.cnf ( ) , , .

Windows. () , . . «#» «; ». - MySQL, . client, MySQL ( mysqld).

. , MySQL, ( «-» ( )). my.cnf .

[client]

port=9999

socket=/dev/mysql

[mysqld]

port=9999

socket=/dev/mysql

set-variable = join_buffer=1M

[mysql]

host=dbhost

unbuffered





My SQL mSQL

MySQL mSQL , . , .



mSQL


msql

msql [options] database

mSQL. mSQL. SQL- , . . , , . . * .


\e

.

\g

.

\

.

\q

.


-f file

.

-h hostname

.

msql2d

msq12d [options]

mSQL. , ( ).


-f file

.

msqladmin

msqladmin [options] command

, . , .


copy database newdatabase

.

create database

.

drop database

.

move database newdatabase

.

reload

.

shutdown

.

stats

. ; , , .

version

.


-f file

.

-h hostname

.

-q


.

msqldump

msqldump [options] database [table]

( ) ANSI SQL.



-

INSERT.

-f file

.

-h hostname

.

-t

; .

-w statement

WHERE .

-V

, .

msqlexport

msqlexport [options] database table

ASCII.



- character

character , .

-h hostname

.

-q character

, .

-s character

, .

-v

, .

msq Iimport

msqlimport [options] database table

ASCII- .



- character

, .

-h hostname

.

-q character

, .

-s character

, .

-V

, .

relshow

relshow [options] [database] [table] [index|_seq]

, , . , . . . , , _seq, .



-f file

.

-h hostname

.


MySQL


isamchk

isamchk [options] table [table...]

( ISAM- - - (Indexed Sequential Access Method). , . ISAM, . /'usr/'local/var/'databasename/tablename.ISM.


-?, --help

.

-# debuglevel, --debug=debuglevel

debuglevel. MySQL . : http://www.turbolift.com/mysql/appen-dixC.html. - d:t:o,/tmp/debugfile.

-a, --analyze

, .

-d, -description

.

-, --extend-check

. , .

-f, --force

. .

-i, --information

.

-k=number, -keys-used=number

(number) . (-k=0), , (bulk load).

-l, --no-symlinks

He .

-q, --quick

.

-r, --recover

. .

-, --safe-recover

, , , <-r>.


-, --set-variable

. . 16 « MySQL mSQL», .

-s, --silent

.

-S, --sort-index

.

-R=index, --sort-records=index

, index.

-U, --unpack

, pack_isam.

-v, --verbose

.

-V, --version

.

-w, --wait

, . , ismchk .

isamlog

isamlog [options] [logfile] [table]

ISAM. ISAM , MySQL -log-isam. ISAM -r. , .



-?, -help

.

-# debuglevel

. : http://www.turbolift.com/mysql/appendixC.html.

- number

(number) .

-f number

. , isamlog . , , isamlog. isamlog , .

-F directory

ISAM.

-i

.

- number

.



-p

.

-r

. .

-R datafile recordnumber

ISAM ( .ISM) , recordnumber.

-u

, .

-v

.

-V

.

-w file

,

-R.

mysql

mysql [options] [database]

MySQL. MySQL. SQL , . database, .

bash, GNU, bash. , tab; Ctrl + a , Ctrl + e, ; Ctrl + , < > .

, . , (go, print . .) . (\g, \p . .) . SQL, \g.



help, ?, \h

.

clear, \c

() .

edit, \e

.

exit.

.

go, \g, ;

.

ego, \G

.

print, \p

.

quit, \q

To , exit,

rehash, \#



.

status, \s

.

use, \u

.



-?, -help

.

-# debuglevel. -debug=debuglevel

. : http://www.turbolift.com/mysql/appendixC.html.

-A, --no-auto-rehash.

.

-, -batch

('batch') . , .

- statement, -execute=statement

. -.

-f, --force

SQL.

-h host, -host=host

.

-, -unbuffered

.

- variable=value, -set-variable variable=value

. . 16, .

-p [password], --password[=password]

, . , .

-P port, -port=port

.

-q, -quick

, . , , , .

-r. -raw

- . -.

-s, --silent

.

-S file, -socket=file

Unix, .

-t, -table

.

-, -debug-info

.

- username, -user=username

, .



-v, -verbose

.

-V, -version

.

-w, -wait

, .

mysqlaccess

mysqlaccess [options] [host] user database

MySQL. . , (wildcards) Unix '*' '?'. , mysqlaccess -commit .



-?, -help

.

-b, -brief

.

-commit

. mysqladmin reload, .

-

, .

-d database, -db=database

, .

-debug=debuglevel

( 0 3).

-h host, -host=host

, .

-howto

.

- host, --rhost=host

.

-old-server

MySQL 3.21.

- password, -password=password

.

-plan

.

-preview

.

- password, -spassword=password

.

--relnotes

.

--rollback

, .

-t,--table

.

- username, -user=username



.

-U username. -superuser=username

.

-v,--version

.

mysqladmin

mysqladmin [options] command [command. . . ]

, . , .



create database

.

drop database

.

extended-status

, , status.

flush-hosts

, .

flush-logs

.

flush-privileges

, reload,

flush-status

.

flush-tables

.

kill thread-id [thread-id...]

mysqld.

password password

.

ping

, MySQL.

processlist

mysqld.

reload

.

refresh

.

shutdown

.

status

.

variables

, .

version

.



-?, -help

.

-# debuglevel, ~debug=debuglevel

. . isamchk .

-f, --force

. .

-h host, --host=host

MySQL .

-i seconds, --sleep=seconds

, .



- [password], --password=[password]

, . , .

- port, --port=port

, .

-s, --silent

.

-S file, --socket=file

Unix, .

- username, --user=username

, .

-V, --version

mysqladmin.

mysqlbug

mysqlbug

MySQL. MySQL MySQL.

mysqld

mysqld [options]

MySQL. , ( ). , safe_mysqld. mysqld .



-?, -I, -help

.

-# debuglevel, -debug=debuglevel

. . Isamchk .

-b directory, --basedir=directory

, .

--big-tables

, .

--bind-addressip-number

IP-, .

-h directory, --datadir=directory

, .

-l [logfile], -log [=logfile]

, . , - hostname, log , hostname - , .



--log-isam[=logfile]

(ISAM). , isam.log. isamlog.

--log-update [=number]

. hostname.num, hostname - , num - , . , .

-L=language, --language=language

(English, French . .), .

-, --new

(, , ) .

-, -old-protocol

3.20.x.

- variable=value, -set-variable variable=value

. . 16, .

--pid-file=file

, (PID) .. hostname, pid , hostname - .

-P port, -port=port

.

-secure

, .

-skip-name-resolve

IP- ( ). .

--skip-networking

.

--skip-thread-priority

.

-S, -skip-new

(, , ) .

-sg

.

-Sl

.

--socket=file

Unix.

-, --exit-info

.

--use-locking

.

-v, -V, --version

.

mysqldump

mysqldump [options] database [table]

( ) ANSI SQL. ; -1 -opt.





-?, --help

.

-# debuglevel, --debug=debuglevel

. : http://www.turbolift.com/mysql/appendixC.html.

-add-drop-table

DROP TABLE CREATE TABLE.

--add-locks

LOCK TABLE .

-allow-keywords

, . , .

-, --compleat-insert

INSERT.

-, --compress

.

--delayed

INSERT DELAYED .

-d, --no-data

, .

-, --extended-insert

INSERT , .

-f, --force

.

-F, --flush-logs

().

--fields-enclosed-by=delimeter

- .

--fields-escaped-by=delimeter

- .

--fields-terminated-by=delimeter

- ( - ).

-h hostname, --host=hostname

.

-l, --lock-tables

.

--lines-terminated-by=delimeter

- .

-t, --no-create-info

He , .

- variable=value, -set-variable variable=value

. . 16, .



--opt

: --add-drop-table, add- locks, --extended-insert, --quick --use-locks.

-P [password], -password [=password]

, . , .

- port, -port=port

, .

-q, -quick

, .

-S file, --socket=file

Unix, .

- directory, --tab=directory

, , , SQL-, . .

-u username, --user=username

, .

-v, --verbose

, .

-V, -version

.

-w statement, --where=statement

, SQL- WHERE.

mysqlimport

mysqlimport [options] database [file]

, ( - ), . , , , .



-?, --help

.

-# debuglevel, -debug=debuglevel

. : http://www.turbolift.com/mysql/appendixC.html.

-d, --delete

, , .

-f, --force

,

--fields-terminated-by=string

, , string.



--fields-enclosed-by=string

, string.

--fields-optionally-enclosed-by=string

, ( ) string .

--fields-escaped-by=string

string .

-h hostname, --host=hostname

.

-I, --ignore

, .

-l, --lock-tables

.

- [password], --password[=password]

, . , .

- port, --port=port

, .

-r, --replace

, .

-s, --silent

.

-S file, -socket=file

Unix, .

-u username, --user=username

, .

-v, --verbose

, .

-V, -version

.

mysqlshow

mysqlshow [options] [database] [table] [field]

, . , . . . , .



-?, -help

.

-# debuglevel, --debug=debuglevel

. : http://www.turbolift.com/mysql/appen-dixC.html.



-h hostname, --host=hostname

.

-k, --keys

.

- [password], -password]=password]

, . , .

- port, --port=port

, .

-S file, --socket=file

Unix, .

- username, --user=username

, .

-V, --version

.




Lite


Lite - , W3-mSQL. Perl. , Lite Perl. Lite Perl.

Lite, W3-mSQL.

chdir

$result = chdir($path)

. , .

chmod

$result = chmod($filename, $mode)

, mode. , . mode , .

chop

$string = chop($string)

, . , read In.

close

close ($fd)

, .

ctime

$time = ctime($time)

time, , Unix.

echo

echo($string)

. .

fprintf

fprintf($fd, $string [, arg ...])

( Perl) . - . , .

gethostbyaddr

$hostinfo = gethostbyaddr($address)

, gethostbyname() IP-. IP- «127.0.0.1». W3-mSQL gethostbyaddr , gethostbyaddress . gethostbyadd ress W3-mSQL.

gethostbyname

$hostinfo = gethostbyname($host)

. - , - IP-.


getpid

$pid = getpid()

(PID) Lite.

getpwnam

$entry = getpwnam($username)

username . :

.

.

UID.

GID.

GECOS ( ).

.

.

getpwuid

$entry = getpwuid($UID)

, , getpwnam ID $UID.

includeFile

includeFile($filename)

filename . .

kill

$result = kill($pid, $signal)

signal pid. , .

link

$result = link($file, $newlinkname)

«» file newlinkname . , .

mkdir

$result = mkdir($directoryname)

. , .

msqIConnect

$socket = msqlConnect($host)

mSQL host. -, . .

msqICIose

msqlClose($socket)

, socket.

msqIDataSeek

msqlDataSeek($result, $location)

'' result . location 0, . msqlFetchRow location.

msqlEncode

$string = msqlEncode($string)

string, mSQL.

msqlFetchRow

$row = msqlFetchRow($result)

result.

msqIFieldSeek

msqlFieldSeek($result, Slocation)



'' , msqllnitFieldList, msqIDataSeek msqlStoreResult . ..



msqIFreeResult

msqlFreeResult($result)

, , msqlStoreRcsult . , .

msqllnitFieldList

$result = msqlInitFieldList($socket, $database, $table)

table database , socket.

msqIListDBs

$databases = msqlListDBs($socket)

, socket.

msqIListField

$tableinfo = msqlListField($result)

, msqllnitFieldList , result. msqIListField , . :











msqIListTables

$tables = msqlListTables($socket, $database)

database , socket.

msqINumRows

msqlNumRows($result)

, result.

msqIQuery

$result = msqlQuery($socket, $query)

query , socket. , .

msqISelectDB

$result = msqlSelectDB($socket, $database)

socket , database . , .

msqIStoreResult

$result = msqIStoreResult

, msqlQuery , .

open

$fd = open($file, $mode)

, , . :



>

<

<>

<

>

<|

>|

pid

$pid = getppid()

(PID) Lite .

printf

printf($string [, arg, ... ])

( Perl) . ; '%s'.

read

$data = read($fd, $length)

length .

readln

$line =readln($fd)

.

readtok

$data = readtok($fd, $token)

, token. token.

rename

$result = rename($oldname, $newname)

( ) oldname newname . , .

rmdir

$result = rmdir($path)

. , .

setContentType

setContentType($string)

HTML-, , , string. . .

sleep

sleep($time)

.

split

$strings = split($string, $token)

, token..

stat

$stat = stat($file)

file. :



inode.

.

.

UID.

GID.

.

Atime.

Mtime.

Ctime.

( ).

.

strftime

$time = strftime($format, $time)

Unix , format. format :

%

.

%

.

%b

.

%

.

%d

(01-31).

%D

% m/% d/% .

%

(1-31, ).

%

(00-23).

%I

(00-12).

%j

(001-366).

%h

(0-23, ).

%l

(1-12, ).

%m

(0112).

%M

(00-59).

%

AM .

%S

(00-59).

%

% :% :% S.

%U

(01-52).

%w

(0-6, 0).

%y

(00-99).

%Y

, ( 1999).

strseg

$string = strseg($string, $start, $end)

, start end .

sub

$string = sub($string, $1, $r2)

exprl string 2. exprl 2 , string .

substr

$string = substr($string1, $regexp, $string2)

string"!, regexp. , , $1, $2, $3 . ., , . string2 , ( $1, $2, $3 . .).



tr

$string = tr($string, $list1, $list2)

listl, string, list2 (, tr("Robby", "oy", "ai") «Rabbi»). , "-". , tr("e.e. cummings", "a-z," "A-Z") «E.E. CUMMINGS.»

truncate

$result = truncate($fale, $length)

length . . , .

umask

umask($mask)

umask mask, , -.

unixtime2*

$year = unixtime2year($time)

$month = unixtime2month($time)

$day = unixtime2day($time)

$hour = unixtirne2hour($time)

$min = unixtime2min($time)

$sec = unixtime2sec($time)

Unix . , unixtime2day(time()) ( 1 31).

unlink

$result = unlink(«filename»)

. , .

urIEncode

$string = urlEncode($string)

string , URL.


PHP


. 3. , MySQL mSQL, , Ababas D, dbm, Oracle PostgreSQL.

abs

$pos_num = abs($number);

Abs number.

addslashes

$escaped_string = addslashes($string); .

string , $ \ '.

asort

$sorted_array = asort($array);

array, asort . sort. , , .

bindec

$decimal = bindec($binary);

binary.

ceil

$higher_integer = ceil($number);

.

chdir

chdir($directory);

, .

chgrp

chgrp($file,Sgroupj;

, .

chimed

chimed($file,$permissions);

permissions . .

chown

chown($file, Sowner);

owner. , , .

chop

$stripped_string = chop($string);

string , , .

chr

$character = chr($number);

ASCII, . 0xff 077 . .


clearstack

clearstack();

. , . , , , . , clearstack() . , . , .

clearstatcache

clearstatcache();

, , . , . - , ( ), clearstatcache(); .

closedir

closed!r($director);

, opendir.

closelog

closelog();

, syslog .

COS

$result = cos($number);

number.

count

$number = count($array);

array. , 1 ( ). array , 0.

crypt

$encrypted_string = crypt($string);

$encrypted_string = crypt($string, $salt);

. Unix - DES, , . . salt ( ).

date

$formatted_date = date($format,$time);

time ( Unix, Time), format. , format, :



/

a am/pm

D ( Sun)

d ( 13)

F ( February)

24- ( 17)

h 12- ( 5)

i ( 30)

l ( Sunday)

( Feb)

m ( 02)

s ( 27)

Y ( 1998)

( 98)

U () ( 803537321)

Z ( 154)

dblist

$db_info = dblist();

, .

decbin

$binary = decbin($decimal);

.

dexhex

$hex = dechex($decimal);

.

decoct

$octal = decoct($decimal);

.

doubleval

$double = doubleval($variable);

.

echo

echo [format_string] expression [, expression ...]

He , , printf . echo expression . , . , , printf Perl.

end

end($array);

array .

ereg

$result = ereg($expression, $string);

$result = ereg($expression, $string, $match_array);

true, string expression . , , , .

eregi

$result = eregi($expression, $string);

$result = eregi($expression, Sstring, $match_array);

ereg, , .

ereg_replace

ereg_replace($expression, $replacement_string, $string);



string , expression , replacement_string.

eregi_replace

eregi_replace($expression, $replacement_string, $string);

ereg_replace, , .

escapeshellcmd

$safe_string = escapeshellcmd(Sstring);

string, , exec system.

eval

eval($string);

string , . , , «», .

exec

$last_line = exec($command);

$last_line = exec($command, $output_array);

$last_line = exec($command, $output_array, $return_code);

Unix command . . , , , . , .

exit

exit();

HTML-.



$result = exp($number);

, .

fclose

fclose($fd);

, fopen.

feof

$result = feof($fd);

true, fd .

fgets

$line = fgets($fd, $max_bytes);

( max_bytes ) , fd.

fgetss

$line = fgetss($fd, $max_bytes);

fgets , HTML .

file

$ = file($filename);

, , filename.

fileatime

$time = fileatime($filename);

( Unix) filename . - , 1.



filectime

$time = filectime($filename);

( Unix) filename . - , -1.

filegroup

$group_id = filegroup($filename);

. - , -1.

fileinode

$inode = fileinode($filename);

filename . - , -1.

filemtime

$time = filemtime($filename);

( Unix) filename . - , -1.

fileowner

$owner = fileowner($filename);

ID . - , -1.

fileperms

$permissions = fileperms($filename);

filename . - , 1.

filesize

$size = filesize($filename);

. - , -1.

filetype

$type = filetype($filename);

,

filename : dir, file, fifo, char, block link.

floor

$lower_integer = floor($number);

number .

flush

flush();

, .

fopen

$fd = fopen($filename, $mode);

mode , . fopen , : «r», «r+», «w», «w+», «a», «+». -1, .



fputs

fputs($fd, $string);

string , fd.

fpassthru

fpassthru($fd);

, fd.

fseek

fseek($fd, $position);

fd ( ), position.

fsockopen

$fd = fsockopen($hostname,$port);

hostname port , . 0, hostname Unix . : -3, ; 4, ( IP-); 5, -; -6, fdopen() , , -7, setvbuf().

ftell

Sposition = ftell($fd);

, fd. fseek.

getaccdir

$directory = getaccdir();

, .

getenv

$value = getenv($variable);

, variable .

gethostbyname

Saddress = gethostbyname($hostname);

IP- hostname .

gethostbyaddr

$hostname = gethostbyaddr($address);

IP .

getimagesize

$file_info_array = getimagesize($filename);

filename. - , - , - . GIF, JPG PNG. «width=xxx height=yyy», HTML <IMG>.

getlastaccess

$time = getlastaccess();

( Unix) . , .



getlastbrowser

$browser = getlastbrowser();

, . , .

getlastemail

$email = getlastemail();

, . , .

getlasthost

$host = getlasthost();

, . , .

getiastmod

$time = getlastmod();

( Unix) . , .

getlastref

$url = getlastref();

URL , . , .

getlogdir

$directory = getlogdir();

, .

get my in ode

$inode = getmyinode();

inode HTML-, .

getmypid

$pid = getmypid();

-.

getmyuid

$id = getmyuid();

HTML-, .

getrandmax

$number = getrandmax();

, rand.

getstartlogging

$time = getstartlogging();

( Unix) HTML, .

gettoday

$hits = gettoday();

, 0 .

gettotal

$hits = gettotal();

.



gettype

$type = gettype($variable);

: «integer», «double» «string», variable .

gmdate

$formatted_date = gmdate($format, $time);

Date , (GMT) .

header

header($header_string);

header_string HTTP-. HTML- , - .

hexdec

$decimal = hexdec($hex);

hex.

htmlspecialchars

$html_string = htmlspecialchars($string);

string, ( <, >, &, " ASCII- 160 255) HTML-.

imagearc

imagearc($image, $, $, $width, $height, $start, $end, $color);

image , color. (, ), width, - height, start end .

imagechar

imagechar($image, $size, $x, $y, $character, $color);

character image , color, size. (, ).

imagecharup

imagecharup($image, $size, $x, $y, $character, $color);

imagechar , , (, ) .

imagecolorallocate

$color = imagecolorallocate($image, $red, $green, $blue);

image, RGB-.

imagecolortransparent

imagecolortransparent($image, $color);

color image.

imagecopyresized



imagecopyresized($dest_image, $src_image, $dest_x, $dest_y, $src_x, $src_y, $dest_width, $dest_heigth, $src_width, $src_heigth);

src_image dest_image , , . dest_x dest_y , a dest_height dest_width - . src_x, src_y,' src_width, src_heigth -.

imagecreate

$image = imagecreate($width, $height);

, .

imagecreatefromgif

$image = imagecreatefromgif($filename);

, filename .

imagedestroy

imagedestroy($image);

, image.

imagefill

imagefill($image, $, $, $color);

image color, (,).

imagefilledpolygon

imagefilledpolygon($image, $points_array, $num_points, $color);

image, color. . - . . . .

imagefilledrectangle

imagefilledrectangle($image, $1, $1, $2, $2, $color);

image, color. 1 1 , 2 2 .

imagefilltoborder

imagefilltoborder($image, $x, $y, $border, $color);

imagefill , , border.

imagegif

imagegif($image);

imagegif($image, $filename);

image GIF. , GIF , .



imageinterlace

imageinterlace($image, $interlace);

image interlace , 1 () 0 ().

imageline

imageline($iraage, $1, $1, $2, $2, $color);

color (1, 2) (2, 2) image.

imagepolygon

imagepolygon($image, $points, $numpoints, $color);

imagef illedpolygon , .

imagerectangle

imagerectangle($image, $1, $1, $2, $2, $color);

imagefilledrectangle , .

imagesetpixel

imagesetpixel($image, $x, $y, $color);

image (, ) , color.

imagestring

imagestring($image, $size, $x, $y, $string, $color);

imagechar , string.

imagestring up

imagestringup($image, Ssize, $x, $y, $string, $color);

imagecharup , string.

imagesx

$x_size = imagesx($image);

, image.

imagesy

$y_size = imagesy($image);

.

include

include($filename);

, filename , . PHP- . filename , PHP_INCLUDE_ PATH.

initsyslog

initsyslog();

syslog. syslog .

intval

$integer = intval($variable);

variable .

isset

$defined = isset($variable);

1, variable , 0.

key

$key = key($array);



array. . .

link

link($target, $filename);

filename target.

linkinfo

$info = linkinfo($filename);

, , filename , ( , ). 1.

log

$result = log($number);

number.

log10

$result = Iog10($number);

10 number.

logas

logas($filename);

filename .

mail

mail($to, $subject, $message);

mail($to, $subject, $message, $headers);

, to, , subject, message . , .

max

$maximum = max($array);

array. , , .

md5

$hash = md5($string);

(MD5) string .

microtime

$ms = microtime();

, ( ), Unix.

min

$minimum = min($array);

array. , , .

mkdir

mkdir($directory, $mode);

directory mode, mode .

mktime

$time = mktime($hour,$minute,$second,$month,$day, Syear);

Unix, . , (, , ).



msql mysql

$result = msql($database, $query);

$result = mysql($database, $query);

query mSQL/MySQL, database. SELECT- 0 mSQL 1.x MySQL, mSQL 2.x . SELECT , msql_ *. -1.

my sql_af f ected_ro ws

$num_rows = mysql_affected_rows();

, INSERT, UPDATE DELETE.

msql_close mysql_close

msql_close(); mysql_close();

mSQL/MySQL.

msql_connect mysql_connect

msql_connect($hostname);

mysql_connect($hostname);

mysql_connect($hostname, Susername);

mysql_connect($hostname, $username, Spassword);

mSQL/MySQL hostname. m(y)sql_connect("localhost"). m(y)sql , . MySQL username username/ password. PHP ( SAFE MODE), username HTML-, -.

msql_createdb mysql_createdb

msql_createdb($database); mysql_createdb($database);

.

msql_dbname mysql_dbname

$db = msql_dbname($result, $i);

$db = mysql_dbname($result, $i);

, i- , m(y)sql_listdbs .

msql_dropdb mysql_dropdb

msql_dropdb($database);

mysql_dropdb($database);

database .

msqHieldflags mysql_fieldflags

$flags = msql_fieldflags($result, $i);

$flags = mysql_fieldflags($result, $i);



i- result. : «primary key», «not null», «not null primary key» << >>.

msql_fieldlen mysql_fieldlen

$length = msql_fieldlen($result, $i);

$length = mysql_fieldlen($result, $i);

i- result.

msql_fieldname mysql_fieldname

$name = msql_fieldname($result, $i);

$name = mysql_fieldname($result, $i);

i- result .-

msql_fieldtype mysql_fieldtype

$type = msql_fieldtype($result, $i);

$type = mysql_fieldtype($result, $i);

i- result ( «char», «real» . .).

msql_freeresult mysql_freeresult

msql_freeresult($result);

mysql_freeresult($result);

, mSQL/MySQL. , , .

mysql_insertjd

$id_num = mysql_insert_id();

, INSERT, auto_increment.

msql_listdbs mysql_listdbs

$result = msql_listdbs();

$result = mysql_listdbs();

, , mSQL/MySQL. m(y)sql_dbname .

msql_listfields mysql_listfields

$result = msql_listfields($database, $table);

$result = mysqllistfields($database, $table);

, table . m(y)sql_fieldflags , m(y)sql_fieldlen , m(y)sql_fieldname m(y)sql_ fieldtype .

msql_isttables mysql_listtables

$result = msql_listtables($database);

$result = mysql_listtables($database);

, database . m(y)sql_tablename .



msql_numfields mysql_numfields

$num_fields = msql_numfields($result);

$nuni_fields = mysql_numfields($result);

result.

msql_nurn rows msql_numrows

$num_rows = msql_numrows($result);

$num_rows = mysql_numrows($result);_

result.

msql_regcase

$new_string = msql_regcase($string);

string, , mSQL.

msql_result mysql_result

$result_string = msql_result($result, $i, $field);

$result_string = mysql_result($result, $1, $field);

field 1- result. field - , table, field , . field MySQL, SELECT, , mysql_result ($result, $i, "length($field)") .

msqljtablename mysql_tablename

$name = msql_tablename($result, $i);

$name = mysql_tablename($result, $i);

, i- , m(y)sql_listtables .

next

next($array);

array .

octdec

$decimal = octdec($octal);

octal.

opendir

opendir($directory);

readdir. closedir .

openlog

openlog($ident, $options, $facllity);

. initlog syslog . , Unix openlog . ident . options : LOG_CONS ( , ); LOG_NDELAY ( ); LOG_PERROR ( stderr); LOG_PID ( (PID) ). ( (LOG_DELAY | LOG_PERROR LOG_PID)). Facility - (, LOG_SYSLOG, LOG_USER, LOG_KERN . .).



ord

$number = ord($character);

ASCII- character.

parse_str

parse_str($string);

URL " 1=1 &2=2" , . .

passthru

passthru($command);

passthru($command, $returevalue);

command . , .

pclose

pclose($fd);

, .

phpinfo

phpinfo();

, . , «?info» URL, ( , http://www.myserver.com/cgi-bin/php).

phpversion

$version = phpversion();

.

popen

$fd = popen($command, $mode);

command ( : mode = «w»), ( mode «r»). , , pclose.

pos

$position = pos($array['element']);

- ' element' ray.

pow

$result = pow($x, $y);

, .

prev

Selement = prev($array);

ray .

putenv

putenv($string);

string . , , .

quote met a

$quoted_string = quotemeta($string);



string, , .

rand

$number = rand();

0 RANDMAX, . , srand . .

readdir

$file = readdir();

. , .

readfile

$filesize = readfile($filename);

filename . , .

readlink

$filename = readline($link);

, link. -1.

reg_match

$result = reg_match($expression, $string);

$result = reg_match($expression, $string, $array);

ereg. .

reg_replace

reg_replace($expression, $replacement, $string);

ereg_replace. .

reg_search

$partial_string = reg_search($expression, $string);

$partial_string = reg_search($expression, $string, $array);

ereg , string , . , . .

rename

rename($oldfile, $newfile);

oldfile newfile .

reset

reset($array);

array .



return

return($value);

value.

rewind

rewind($fd);

f d .

rewinddir

rewinddir();

.

rmdir

rmdir($directory);

directory , .

rsort

$sorted_array = rsort($array)

array. , , .

setcookie

setcookie($name);

setcookie($name, $value, $expire, $path, $domain, $secure);

cookie . name, cookie . "" ( 0 expire secure).

seterrorreporting

seterrorreporting($value);

value 0, , .

setlogging

setlogging($value);

value , , - .

setshowinfo

setshowinfo($value);

value , .

settype

settype($variable, $type);

variable type, integer, double string .

shl

$value = shl($number, $b);

number, b .

shr

$value = shr($number, $b);

number, b .

sin

$value = sin($number);

number ( ).

sleep

sleep($seconds);

.

sort

$sorted_array = sort($array)

array. , , .



soundex

$soundex_key =soundex($string);

soundex string .

sprintf

$string = sprintf($format, $arg, [$arg, $arg, ...]);

format, printf arg. 5 .

sqrt

$value = sqrl($number);

number.

srand

srand($integer);

integer. ( ) , rand.

strchr strstr

$substring = strchr($string, $value);

$substring = strstr($string, $value); .

string value , strchr strstr - , .

strtr

strtr($string, $set1, $set2);

string, setl, set2. set1 set2, set2 «» set1. set2 set1, «» set2 .

stripslashes

$plain_string = stripslashes($escaped_string);

escaped_string .

strlen

$length = strlen($string);

string .

strrchr

$substring = strrchr($string, $character);

string . , , character. , .

strtok

$substring = strtok($string, $characters);

$substring = strtok($characters);

string , , characters . strtok , , string .



strtolower

$lc_string = strtolower($string);

string , .

strtoupper

$uc_string = strtoupper($string);

string , .

strval

$string = strval($variable);

variable .

substr

$substring = substr($string, $start, Slength);

string , start (0 ) length .

symlink

symlink($target, $filename);

() filename target.

syslog

syslog($level, $message);

message level.

system

$results = system($command);

$results = system($command, $return_value);

command . , ( ) .

tan

$value = tan($number);

number ( ).

tempnam

$filename = tempnam($path, $prefix);

prefix, , path.

time

$time = time();

Unix ( 1 1970 ).

umask

$umask = umask();

umask($umask);

umask, . umask , umask ( ).

uniqid

$result = uniqid();

, , , .

unlink

unlink($filename);

.

unset

unset($variable);

, . .

urldecode

$decoded_string = urldecode($string);

string, URL . .

urlencode

$encoded_string = urlencode($string);

string, URL.

usleep

usleep($ms);

ms .

virtual

virtual($filename);

filename , HTML <!--#include virtual=»$filename» --> . - Apache.




MSQLCAPI


API mSQL 2 mSQL 1. , . mSQL 2, .


mSQL API . 'msql.h', , mSQL.

m_result

, SELECT ( SHOW). m_row.

m_row

, SELECT. mSQL ( ).

m_field

, , . m_field :

char *name

.

char *table

, . (null), .

int type

. , mSQL SQL, msql.h.

int length

.

int flags

. - :

IS_PRI_KEY(flags)

true, .

IS_NOT_NULL(flags)

true, NOT NULL.

msqIConnect

int msqIConnect ( char*host )

mSQL IP-. , mSQL , Unix. , . 1.


/* */


dbh = msqlConnect( (char*)NULL );

if (dbh == -1) {

print " !\n";

exit(1); }

msqISelectDB

int msqISelectDB ( int sock , char*dbName )

. , . 1.



/* "mydatabase" */

result = msqlSelectDB( dbh, "mydatabase" );

if (result == -1) {

print " ! \n";

exit(1); }

msqIQuery

int msqlQuery( int sock , char*query )

SQL-. mSQL 2 , ( SELECT). mSQL 1 . 1.



rows_returned = msqlQuery( dbh, "SELECT FROM people" );

msqIStoreResult

m_result *msqlStoreResult()

SELECT. msqIQuery SELECT. m_result. . m_result msqlFreeResult .



m_result *results;

rows_returned = msqlQuery( dbh, "SELECT FROM people" );

results = msqlStoreResult();

IK. 897

/* 'results'. */

msqIFreeResult

void msqIFreeResult ( m_result*result )

, m_result.



m_result "results;

rows_returned = msqlQuery( dbh, "SELECT FROM people" );

results = msqlStoreResult();

/* */

msqIFreeResult(results);

msqIFetchRow

m_row msqIFetchRow ( m_result*result )

. m_row, . msqIFetchRow , , .





m_result *results;

m_row "row;

rows_returned = msqlQuery( dbh, "SELECT FROM people" );

results = msqlStoreResult();

row = msqlFetchRow(results);

printf(" : %s\n", row[2]);

msqlDataSeek

void msqlDataSeek ( m_result* result, int pos )

, msqIFetchRow, . . 0, . , .



m_result *results;

m_row Vow;

rows_returned = msqlQuery( dbh, "SELECT FROM people" );

results = msqlStoreResult();

row = msqlFetchRow(results);

/* */ msqlDataSeek(results, 0);

msqINumRows

int msqINumRows ( m_result*result )

.



rows_returned = msqlQuery( dbh, "SELECT FROM people" );

results = msqlStoreResult(); rows = msqlNumRows(results);

msqIFetchField

m_field "msqIFetchField ( m_result*result )

. msqIFetchField m_f ield , , .



m_field *field;

rows_returned = msqlQuery( dbh, "SELECT FROM people" );

results = msqlStoreResult();

field = msqlFetchField(results);

/* 'field'

*/

field = msqlFetchField(results);

/* 'field' */

msqlFieldSeek

void msqlFieldSeek ( m_result*result , int pos )

, msqlFetchField . , , , .



m_result "results; m_field 'field;



rows_returned = msqlQuery( dbh, "SELECT FROM people" );

results = msqlStoreResult();

field = msqlFetchField(results);

/* */

msqlFieldSeek(results, .0);

msqlNumFields

int msqlNumFields ( m_result* result )

.



rows_returned = msqlQuery( dbh, "SELECT FROM people" );

results = msqlStoreResult();

fields = msqlNumFields(results);

msqICIose

int msqICIose ( int sock )

mSQL.



dbh = msqlConnect( (char')NULL );

/* Do work */

msqlClose(dbh);

msqIListDBs

m_result *msqlListDBs ( int sock )

m_result, , . m_result, , , msqlFreeResult .



databases = msqlListDBs(dbh);

/* 'databases' */

msqIListTables

m_result *msqIListTables ( int sock )

m_result, . m_result, , , msqlFreeResult .



tables = msqlListTables(dbh);

/* 'tables' */

msqIListFields

m_result 'msqIListFields ( int sock , char*tableName )

m_result, . m_result, , , msqlFreeResult .



fields = msqlListFields(dbh, "people");

/* 'fields'

'people' */

msqIListlndex

m_result 'msqIListlndex ( int sock , char*tableName , char*index )

m_result, . ( 'avl') . m_result, , , msqlFreResult .



index = msqll_istIndex(dbh, "people", "idx1");

/* 'index' 'idx1' 'people' */


MySQL API


MySQL API . 'mysql.h', , MySQL.


MYSQL

, . .

MYSQL_FIELD

, , . , MySQL, , . :

char *name

.

char *table

, . , , .

char *def

, . null mysql_list_f ields, , .

num enum_field_types type

. MySQL SQL.

unsigned int length

, .

unsigned int max_length

mysql_list_fields , .

unsigned int flags

. :

NOT_NULL_FLAG

,

NULL. PRI_KEY_FLAG

, .

UNIQUE_KEY_FLAG

, .

MULTIPLE_KEY_FLAG

, .

BLOB_FLAG

, BLOB TEXT.

UNSIGNED_FLAG

, .

ZEROFILL_FLAG

, ZEROFILL.

BINARY_FLAG


, CHAR VARCHAR BINARY.

ENUM_FLAG

, ENUM.

AUTO_INCREMENT_FLAG

, AUTO_INCREMENT.

TIMESTAMP_FLAG

, TIMESTAMP.

unsigned int decimals

.

MYSQL_FIELD :

IS_PRI_KEY( flags)

true, .

IS_NOT_NULL(flags)

true, NOT NULL.

IS_ELOE(flags)

true, BLOB TEXT.

IS_NUM(type)

true, .

MYSQL_FIELD_OFFSET

, «» ().

MYSQL_RES

, SELECT ( SHOW). MYSQL_ROW.

MYSQL_ROW

, SELECT. , MySQL, ( ).

my_ulonglong

, MySQL. 0 1.819, 1 .

my sql_affected_ro ws

my_ulonglong mysql_affected_rows(MYSQL*mysql)

, . SELECT mysql_num_rows ( ). mysql_query, .



/* 'people' */

mysql_query(&mysql, "INSERT INTO people VALUES ('', 'Illyana Rasputin',

16)";

num = fflysql_affected_rows(&mysql);

/* INSERT , num 1, -1, */

mysql_close

void mysql_close(MYSQL*mysql)

MySQL. , , mysql_err.





mysql_close(&mysql);

/* */

mysql_connect

MYSQL *mysql_connect(MYSQL*mysql, const char*host, const char*user, const char *passwd)

MySQL. MYSQL. - IP- MySQL. localhost, MySQL . - . . MYSQL, , NULL, . ( , - .)

MySQL, mysql_real_connect.



/* MySQL, "bob"

"mypass" */ MYSQL mysql;

if(!mysql_connect(&mysql, "", "bob", "mypass")) {

printf("Oa !\n");

exit(0); }

/* , , */

mysql_create_db

int mysql_create_db(MYSQL*mysql, const char*db)

. , , .

MySQL. MySQL SQL CREATE DATABASE. mysql_query.



/* 'new_database' */

result = mysql_create_db(&mysql, "new_database");

mysql_data_seek

void mysql_data_seek(MYSQL_RES*res, unsigned int offset)

. MYSQL_RES, . , . - 0. , mysql_store_ result.





/* */

mysql_data_seek(results, mysql_num_rows(results)-1);

mysql_debug

mysql_debug(char *debug)

, . MySQL Fred Fish, , .



/* .

"debug.out"*/

mysql_debug("d:t:0, debug. out");

mysql_drop_db

int mysql_drop_clb(MYSQL*mysql, const char*db)

. , , .

MySQL. MySQL SQL DROP DATABASE. mysql_query mysql_drop_db.



/* 'old_database' */

result = mysql_drop_db(&mysql, "old_database");

mysql_dump_debug_info

int mysql_dump_debug_info(MYSQL*mysql)

. Process . .



result = mysql_dump_debug_info(&mysql);

/*

*/

mysql_eof

my_bool mysql_eof(MYSQL_RES* result)

, . . , mysql_use_result.



/* */

while((row = mysql_fetch_row( results.))) {

/' 7 }



if(!mysql_eof(results))

{

printf(". .\n");

mysql_errno

unsigned int mysql_errno(MYSQL*mysql)

, . , .



error = mysql_errno(&mysql);

printf("HoMep : %d\n", error);

mysql_error

char *mysql_error(MYSQL*mysql)

, . , .



printf(" : '%s'\n", mysql_error(&mysql));

mysq l_esca pe_strin g

unsigned int mysql_escape_string(char*to, const char "from, unsigned int

length)

unsigned int mysql_escape_string(char*to, const char *from)

, MySQL. - , , ( to >= from*2+l). , , . , .



char name[15] = "Bob Marley's";

char enc_name[31];

mysql_escape_string(enc_name, name);

/* enc_name "Bob Marley\'s" (

).

mysql_fetch_field

MYSQL_FIELD*mysql_fetch_field(MYSQL_RES* result)

MYSQL_FIELD, . , , .



MYSQL_FIELD*field;

while((field = mysql_fetch_field(results)))

{

/* */

}

mysql_fetch_field_direct

MYSQL_FIELD * mysql_fetch_field_direct(MYSOL_RES * result, unsigned int fieldnr)



mysql_fetch_field , , . - 0.



MYSQL_FIELD *field;

/* */

field = mysql_fetch_field_direct(results, 2);

mysql_fetch_fields

MYSQL_FIELD *mysql_fetch_fields(MYSQL_RES* result)

mysql_fetch_field , MYSQL_FIELD, .



MYSQL_FIELD 'field; MYSQL_FIELD 'fields;

/* */

fields = mysql_fetch_fields(results);

/* 'field' */

field = fields[2];

mysql_fetch_lengths

unsigned long *mysql_fetch_lengths(MYSQL_RES*result)

. . ( mysql_fetch_row) . , BLOB VARCHAR, .



unsigned long *lengths;

row = mysql_fetch_row(results);

lengths = mysql_fetch_lengths(results);

printf("Tpetbe %d \n", lengths[2]);

mysql_fetch_row

MYSQL_ROW mysql_fetch_row(MYSQL_RESresult)

MYSQL__ROW. , . MY.SQI _ROW - , .



MYSQL_ROW row;

row = mysql_fetch_row(results);

printf(" : %s\n", row[2]);

mysql_field_seek

MYSQL_FIELD_OFFSET mysql_field_seek(MYSQL_RES *result, MYSQL_FIELD_OFFSET offset)

. , , mysql_fetch_field. MYSQL_FIELD_OFFSET , mysql_field_tell ( mysql_f ield_seek). 0, . .





MYSQL_FIELD field;

/* */

old_pos = mysql_field_seek(results, 0);

/* */

field = mysql_field_field(results);

/* */

mysql_field_seek(results, old_pos);

mysql_field_tell

MYSQL_FIELD_OFFSET mysql_field_tell(MYSQL_RESresult)

. mysql_f ield_seek.



MYSQL_FIELD fieldl, field2, fieldS;

/* */

old_pos = mysql_field_tell(results);

/* */

field1 = mysqLfield_field(results);

field2 = mysql_field_field(results);

field3 = mysql_field_field(results);

/* */

mysql_field_seek(results, old_pos);

mysql_free_result

void mysql_free_result(MYSQL_RESresult)

, MYSQL_RES. .



MYSQL_RES "results;

/* */

mysql_free_result(results);

mysql_get_client_info

char *mysql_get_client_info(void)

MySQL, .



printf("a MySQL %s\n",

mysql_get_client_info()));

mysql_get_host_jnfo

char *mysql_get_host_info(MYSQL*mysql)

, MySQL (, Unix- TGP).



print(" : %s", mysql_get_host_info(&mysql));

mysq l_get_proto_i nf

unsigned int mysql_get_proto_info(MYSQtmysql)

MySQL, .



printf("o MySQL %d\n",

mysql_get_proto_info());

mysql_get_server_info



char *mysql_get_server_info(MYSQL*mysql)

, MySQL, .



printf("B MySQL %s\n", mysql_get__server_info(&mysql);

mysqljnfo

char *mysql_info(MYSQL*mysql)

, , . SQL-: INSERT INTO ( SELECT); LOAD DATA INFILE; ALTER TABLE; INSERT INTO TABLE ( ). (, ), .



/* LOAD DATA INFILE,

*/ printf(" : %s\n", mysql_info(&mysql));

mysql_init

MYSQL *mysql_init(MYSQL*mysql)

MYSQL, MySQL. mysql_real_connect, . MYSQL , MYSQL . mysql_close. , .



MYSQL mysql;

if (!mysql_init(&mysql)) {

printf(" MySQL\n");

exit(1); }

mysqljnsertjd

my_ulonglong mysql_insert_id(MYSQL*mysql)

, AUTO_INCREMENT. AUTO_INCREMENT, , .



/* ID

*/



id = mysql_insert_id(&mysql);

printf('' ID %d\n", id);

mysql_kill

int mysql_kill(MYSQL*mysql, unsigned long pid)

MySQL ID (PID). . , Process .



/* 4 */

result = mysql_kill(&mysql, 4);

mysql_list_dbs

MYSQL_RES*mysql_list_dbs(MYSQL*mysql, const char*wild)

MYSQL_RES, , , . SQL. , . MYSQL_RES, , , mysql_f ree_result. .



MYSQL_RES databases;

databases = mysql_list_dbs(&mysql, (char*)MULL);

/* 'databases' MySQL */

mysql_list_fields

MYSQL_RES *mysql_list_fields(MYSQL*mysql, const char*table, const char *wild)

MYSQL_RES, , , . SQL. , . MYSQL_RES, , , mysql_free_result. .



MYSQL_RES fields;

fields = mysql_list_fields(&mysql, "people", "address%");

/* 'fields' 'people', 'address' */

mysql_list_processes



MYSQL_RES*mysql_list_processes(MYSQL*mysql)

MYSQL_RES, , MySQL. mysql_kill , . MYSQL_RES, , , mysql_f ree_result. .



MYSQL_RES threads;

threads = mysql_list_processes(&mysql);

mysql_list_tables

MYSQL_RES*mysql_list_tables(MYSQL*mysql, const char*wild)

- MYSQL_RES, , , . SQL. , . MYSQL_RES, , , mysql_f ree_result. .



MYSQL_RES tables;

tables = mysql_list_tables(&mysql, "p%");

/* 'tables' , '' */

mysql_num_fields

unsigned int mysql_num_fields(MYSQL_RESresult)

, .



num_fields = mysql_num_fields(results);

printf("There are %d fields in each row\n", num_fields);

mysql_num_rows

int mysqi_num_rows(MYSQL_RESresult)

. , mysql_store_result. mysql_use_result, , mysql_num_rows, , .



num_rows = mysql_num_rows(results);

printf(" %d \n", num_rows);



mysql_ping

int mysql_ping(MYSQL*mysql)

MySQL. , . , , .



while(mysql_ping(&mysql))

printf(", ...\n");

mysql_query

int mysql_query(MYSQL*mysql, const char"query)

SQL-, . ( (null)), , mysql_real_query. , , .



error = mysql_query(&mysql, "SELECT FROM people WHERE name like

'Bill%'");

if (error) {

printf(" !\n");

exit(1);

}

mysql_real_connect

MYSQL *mysql_real_connect(MYSQL*mysql, const char*host, const char *user,

const char *passwd, const char*db, uint port, const char*unix_socket, uint client_flag)

MySQL. :

MYSQL, mysql_init.

IP- MySQL ( MySQL Unix localhost).

, ( , ).

, . , .

, ( , ).

, MySQL TCP ( , 0).



Unix ( , ).

, :

CLIENT_FOUND_ROWS

, , , , .

CLIENT_NO_SCHEMA

database, table.column , .

CLIENT_COMPRESS

.

CLIENT_ODBC

, ODBC.



/* ,

. */

if (! mysql_real_connect(&mysql, "localhost", "bob", "mypass", "", 0, 0))

{

print " !\n";

exit(1); }

mysql_real_query

int mysql_real_query(MYSQL*mysql, const char*query, unsigned int length)

SQL-, . . , , (null) . , mysql_query. , , .



error = mysql_real_query(&ntysql, "SELECT FROM people WHERE name like Bill%'",

44);

if (error)

{

printf(" !\n");

exit(1);

}

mysql_reload

int mysql_reload(MYSQL*mysql)

MySQL. Reload . , , .



result = mysql_reload(&mysql);

mysql_row_tell

unsigned int mysql_row_tell(MYSQL_RESresult)

, mysql_fetch_row . mysql_row_seek .





saved_pos = mysql_row_tell(results);

/* */

mysql_select_db

int mysql_select_db(MYSQL*mysql, const char*db)

. . , , .



result = mysql_select_db(&mysql, "newdb");

mysql_shutdown

int mysql_shutdown(MYSQL*mysql)

MySQL. Shutdown . , , .



result = mysql_shutdown(&mysql);

mysql_stat

char *mysql_stat(MYSQL*mysql)

. , .



printf(" \n-------\n%s\n", mysql_stat(&mysql));

mysql_store_result

MYSQL_RES *mysql_store_result(MYSQL*mysql)

MYSQL_RES. , mysql_use_result. mysql_f ree_result MYSQL_RES . .



MYSQL_RES results;

mysql_query(&mysql, "SELECT* FROM people");

results = mysql_store_result(&mysql);

/* 'results' 'people*/

mysql_thread_id

unsigned long mysql_thread_id(MYSQL* mysql)

ID . mysql_kill .



thread_ld = mysql_thread_id(&mysql);

mysql_use_result

MYSQL_RES*mysql_use_result(MYSQL*mysql)



MYSQL_RES. , mysql_store_result. , , mysql_store_result, . , . . mysql_f ree_result MYSQL_RES. .



MYSQL_RES results;

mysql_query(&mysql, "SELECT* FROM people");

results = mysql_store_result(&mysql);

/* 'results' ( mysql_fetch_row), */





Python

Python, MySQL mSQL. . API . API API, Python Database SIG. mSQL API.



: mSQL


mSQL MySQL. mSQL.connect(). mSQL, mSQL.

: mSQL.connect()


connection - mSQL.connect()

connection - mSQL.connect(host)


mSQL . , . mSQL, .


connection = mSQL.connect('carthage.imaginary, com')

: cormection.selectdb()


connection, selectdb(database)


. , .


connection.selectdb('test');

: connection.query()


results = connection. query(sq1)


SQL. , . , .


results = conn.query('SELECT title, year FROM movies');

rowl = results[0];

: connection.listdbs()


dbs - connection. listdbs()


.


dbs = conn.listdbs()

: connection.listtables()


connection.listtables()


, .


tables = conn.listtables()

: connection.serverinfo


mSQL, .


info = connection.serverinfo;

: connection.hostname


, mSQL.


host = connection.hostname



: MySQL


Python MySQL MySQL.connect(). , , MySQL, MySQL.

: MySQL.connect()


connection = MySQL.connect(host)


MySQL . connect() , MySQL . Python, MySQL.


conn = MySQL.connect('carthage.irnaginary.com');

: connection.selectdb()


connection, selectdb(database)


, .


connection. selectdb('test');

:

connection.do()


results = connection.do(sql)


SQL . , . , .


results = conn.do('SELECT title, year FROM movies');

row1 = results[0];

: connection.query()


statement_handle = connection. query(sgl)


do(), SQL- . do() , - , SQL, .


hndl = conn. query(' SELECT title, year FROM movies');

: statement_handle.affectedrows()


rowcount = statement_handle.affectedrows()


, SQL UPDATE, DELETE INSERT, , .


rowcount = hnd1.affectedrows()


: statement_handle.numrows()



rowcount = statement_handle.numrows()



, SELECT, .



rowcount = hndl. numrows()

: statement_handle.fields()



list = statement_handle.fields()



, . . - . , . , - . .

:

, .

, , .

SQL .

int, .

, , NOTNULL.



flds = hndl.fields();

for column in fids: name = column[0];

table = column[1]; type = column[2];

size = columns[3]; mods = column[4];

: statement_handle.fetchrows()



list = statement_handle.fetchrows(rownum)



, . 1, . , . , . .



rows = hndl.fetchrows(-l);

for row in rows:

coll = row[0]; 12 = row[1];

: connection.listdbs()



dbs = connection.listdbs()



.



dbs = conn.listdbs()

: connection.listtables()



tables = connection. listtables();



, .



tables = conn. listtables();




DBI.pmAPI


DBI API API Perl. , MsqPerl MysqlPerl , DBI.

use

use DBI;

Perl, DBI.

DBI::available_drivers

@available_drivers = DBI->available_drivers;

@available_drivers = DBI->available_drivers($quiet);

DBI: :available_drivers DBD. , DBD Perl. true, DBD . Msql-Mysql mSQL 'mSQL', MySQL - 'mysqP.


use DBI;

my @drivers = DBI->available_drivers;

print " :\n" . join("\n",@drivers) . "\n Ho mSQL mysql. :)\n";

DBI::bind_col

$result = $statement_handle->bind_col($col_num, \$col_variable, \%unused);

DBI: :bind_col SELECT Perl. . , 1. Perl, . . DBD: :mysql DBD: :mSQL . - undef.


use OBI;

my $db = DBI->connect('DBI:mSQL:mydata', undef,undef);

my $query = "SELECT name, date FROM myothertable";

my $myothertable_output = $db->prepare($query);

my ($name, $date);

$myothertable_output->bind_col(1,\$name,undef);

$myothertable_output»bind_col(2, \$date, undef);

# $name Sdate .


$myothertable_output->execute;

while ($myothertable_output->fetch) {

# $name $date .

print ": $name : $date\n"; }

DBI::bmd_columns

$result = $statement_handle->bincl_columns(\%unused, @list_of_refs_to_vars);

DBI: : bind_columns . - , DBI: :bind_col . DBD::mSQL DBD::mysql . . \($var1, $var2) . , , .



use DBI;

my $db = DBI->connect('DBI:mSQL:mydata',undef,undef);

my $query = "SELECT name, date FROM myothertable";

my $myothertable_oulput = $db->prepare($query);

my ($name, $date);

$mynfhertable_outpul->bind_columns(undef, \($name, $daLe));

# $name $date ,

$myothertable_output->execute;

while ($myothertable_output->fetch)

{

# $name $date .

print ": $name : $date\n";

}

DBI::bind_param

$result = $statement_handle->bind_param($param_number, $bind_value);

$result = $statement_handle->bind_param($param_number, $bind_value, $bind_type);

$result = $statenent_handle->bind_param($param_number, $bind_value, \%bind_type);

DBI: : bind_param - '?' (. OBI:: prepare). - - , 1 ( ). - . . { TYPE => &DBI:: SQL_TYPE } , 'SQL_TYPE' - . DBI SQL- () SQL_CHAR, SQL_NUMERIC, SQL_DECIMAL, SQL_INTEGER, SQL_SMALLINT, SQL_FLOAT, SQL_REAL, SQL_DOUBLE SQL_VARCHAR. , DBD::mSQL DBD::Mysql, . 21-1 . , undef.



21-1. SQL



DBI



MSQL



MySQL



SQL_CHAR



CHAR TYPE



FIELD TYPE CHAR







IDENT TYPE



FIELD TYPE DATE







NULL TYPE



FIELD TYPE DATETIME







DATE TYPE



FIELD TYPE NULL







MONEY TYPE



FIELD TYPE TIMESTAMP







TIME TYPE



FIELD TYPE TIME







IDX TYPE











SYSVAR TYPE











ANY TYPE







SQL_NUMERIC







FIELD TYPE LONG FIELD TYPE LONGLONG FIELD_TYPE_SHORT



SQL_DECIMAL







FIELD_TYPE_DECIMAL



SQLJNTEGER



INT_TYPE



FIELD_TYPE_INT24



SQL SMAL-LINT



UINT_TYPE



FIELD_TYPE_INT24



SQL_FLOAT







FIELD_TYPE_FLOAT



SQL_REAL



REAL TYPE LAST_REAL_TYPE



FIELD JTYPE_DOUBLE



SQLJDOUBLE







FIELD_TYPE_DOUBLE



SQL_VARCHAR



TEXT_TYPE



FIELD_TYPE_TINY BLOB FIELD_TYPE_MEDIUM BLOB FIELD TYPE BLOB FIELD TYPE LONG BLOB FIELD TYPE VAR STRING FIELD TYPE STRING



use DBI;

my $db = DBI->connect('DBD:msql:mydata','me','mypass');

my Sstatement = $db->prepare(

"SELECT name, date FROM myothertable WHERE name like ? OR name like ?");

$statement->bind_param(1,'J%','SQL_CHAR');

$statement->bind_param(2,'%oe%', { TYPE => &DBI::SQL_CHAR });

# :

# SELECT name, date FROM myothertable WHERE name like 'J%' or name like

'%oe%'

DBI::connect

$db = DBI->connect($data_source, $username, $password);

$db = DBI->connect($data_source, $username, $password, \%attributes);

DBI:: connect . . . DBI: :data_sources . mSQL MySQL 'DBI:mSQL:$database:Shostname:Sport' 'DBI:mysql:Sdatabase:Shostname:Sport' . :Sport . ': Shostname: Sport' Unix. .



. mSQL 'undef'. 'jndef MySQL, , , .

. . PrintError, RaiseError AutoCommit. 0, - - . -) PrintError AutoCommit , a RaiseError - . mSQL, MySQL , AutoCommit ( . ).

undef, $DBI;:errstr .



use DBI;

my $db1 = DBI->connect('DBI: mSQL:mydata',undef,undef);

# $db1 'mydata'

# mSQL.

my $db2 = DBI->connect( 'DBI:mysql:mydata:myser-ver.com','me','mypassword');

# $db2 'mydata' MySQL

# 'myserver.com' .

# '' 'mypassword'.

my $db3 = DBI->connect('DBI:mSQL:mydata',undef,undef, {

RaiseError => 1 });

# $db3 - , $db1, ,

# 'RaiseError'.

DBI::data_sources

@data_sources = DBI->data_sources($dbd_driver);

DBI: :data_sources DBD - " , DBI::connect . , DBD. Msql-Mysql mSQL 'mSQL', MySQL -'mysql'.





use DBI;

my §msql_data_sources = DBI->data_sources('mSQL');

my @mysql_data_sources = DBI->data_sources('mysql');

# DBD::mSQL DBO::mysql,

# .

print "mSQL databases:\n" . join("\n",@msql_data_sources) , "\n\n";

print "MySQL databases:\n" . join("\n",@mysql_data_sources) . "\n\n";

DBI::do

$rows_affected = $db->do($statement);

$rows_affected = $db->do($statement, \%unused);

$rows_affected = $db->do($statement, \%unused, @bind_values);

DBI: : do SQL-, SELECT, . , DBI: :prepare/DBI: :execute , . - SQL. DBD::mSQL DBD::mysql, DBD . - - '?'. . DBI: : do .



use DBI;

my $db = DBI->connect('DBI:mSQL:mydata',undef,undef);

my $rows_affected = $db->do("UPDATE mytable SET name='Joe' WHERE name='Bob"');

print "$rows_affected Joe Bob's\n";

my $rows_affected2 = $db->do("INSERT INTO mytable (name) VALUES (?)", {}, ("Sheldon's Cycle"));

#

#

#INSERT INTO mytable (name) VALUES ('Sheldon's Cycle')

DBI-disconnect

$result = $db->disconnect;

DBI: : disconnect . mSQL MySQL , , . , , . , , . , $DBI: :errstr .





use DBI;

my $db1 = DBI->connect( 'DBI:mSQL:mydata',undef,undef);

my $db2 = OBI->connect('DBI:mSQL:mydata2',undef,undef);

$db1->disconnect;

# 'mydata' . 'mydata2'

# .

DBI::dump_results

$neat_rows = DBI::dump_results($statement_handle);

$neat_rows = DBI::dump_results($statement_handle, Smaxlen);

$neat_rows = DBI::dump_results($statement_handle, $maxlen, $line_sep);

$neat_rows = DBI::dump_results($statement_handle, $maxlen, $line_sep,$field_sep);

$neat_rows = DBI::dump_results($statement_handle, $maxlen, $line_sep,$field_sep, $file_handle);

DBI: : dump_results , DBI: :neat_string . . - . , , , 35. , , - \n. , , . , . STDOUT. , undef.



use DBI;

my $db = DBI->connect('DBI:mSQL:mydata',undef,undef);

my Squery = "SELECT name, date FROM myothertable";

my $myothertable_output = $db->prepare($query);

$myothertable_output->execute;

print DBI::dump_results($myothertable_output);

# .

open(MYOTHERTABLE, ">>myothertable");

print DBI: :dump_results($iriyothertable_output,

undef,undef,undef,\*MYOTHERTABLE);

# 'myothertable,'.

$DBI::err

$error_code = $handle->err;



$DBI:: err DBI. , $DBI: :errstr. $DBI: :err . , .



use DBI;

my $db = DBI->connect('DBI:mysql:mydata',

'webuser','super_secret_squirrel');

# ...

my Soutput = $db->prepare('SLECT * from mydata');

$output->execute;

if (not $output) {

print "Error $DBI:err: $DBI:errstr\n"; }

$DBI::errstr

$error = $handle->errstr;

DBI. , . , undef. $DBI: :errstr . , .



Use DBI;

my $db = DBI->connect('DBI:mysql:mydata',

'wcbuscr','super_secret_squirrel');

my $error = $db->errstr;

warn("Boj DBI: $error");

DBI::execute

$rows_affected = $statement_handle->execute;

$rows_affected = $statement_handle->execute(@bind_values);

DBI: : execute SQL-, . , SELECT, . -1, . SELECT . , - (. DBI: : prepare ).



use DBI;

my $db = DBI->connect('OBI:mSQL:mydata',undef,undef);

my $statement_handle = $db->prepare("SELECT * FROM mytable");

my $statement_handle2 = $db->prepare("SELECT name, date FROM myothertable WHERE name like ?");

$statement_handle->execute;

# .

# .



$statement_handle->execute("J%");

# :

# SELECT name, date FROM myothertable WHERE name like 'J%'

DBI::fetchall_arrayref

$ref_of_array_of_arrays = $statement_handle->fetchall_arrayref;

DBI: :fetchall_arrayref . - , . , undef. DBI: :fetchrow_ *, DBI: :fetchall_arrayref , DBI: : fetch row *.



use DBI;

my $db = DBI->connect('DBI:mSQL:mydata' ,undef,undef);

my $query = "SELECT name, date FROM myothertable";

my Soutput = $db->prepare($query);

$output->execute;

my $data = $output->fetchall_arrayref;

# $data .

# '' , .

print " : " . $data->[3][1]. "\n";

# 3 '' ,

# , # 1 .

DBI::fetchrow_array

@row_of_data = $statement_handle->fetchrow;

DBI: : fetch row , DBI: :execute . DBI: : fetchrow . , undef. . SELECT * FROM . . . , , .



use DBI;

my $db = DBI->connect('DBI:mSQL:mydata',undef,undef);

my $query = "SELECT name, date FROM myothertable WHERE name LIKE 'Bob%'";



my $myothertable_output = $db->prepare($query);

$myothertable_output->execute;

my ($name, $date);

# $myothertable_output.

($name, $date) = $myothertable_output->fetchrow_array;

# ...

($name, $date) = $myothertable_output->fetchrow_array;

# ...

my @name_and_date = $myothertable_output->fetchrow_array;

# ......

DBI::fetchrow_arrayref, DBI::fetch

$rr_r = $statement_handle->fetchrow_arrayref;

$array_reference = $statement_handle->fetch;

DBI: : fetchrow_arrayref DBI: : fetch , DBI: :fetchrow_array , , .



use DBI;

my $db = DBI->connect('DBI:mSQL:mydata', undef, undef);

my $query = "SELECT name, date FROM myothertable WHERE name LIKE -Bob%'";

my $myothertable_output = $db->prepare($query);

$myothertable_output->execute;

my $name1 = $myothertable_output->fetch->[0]

# 'name' ,

my $date2 = $myothertable_output->fetch->[1]

# 'date' .

my ($name3, $date3) = @{$myothertable_output->fetch};

# .

$myothertable_output->fetch

# . ''

# , @{}.

DBI::fetchrow_hashref

$hash_reference = $statement_handle->fetchrow_hashref;

DBI: :fetchrow_hashref , OBI: :fetchrow_arrayref , , . , - .



use DBI;

my $db = DBI->connect('DBI:mSQL:mydata',undef,undef);

my $query = "SELECT * FROM mytable";

my $mytable_output = $db->prepare($query);

$mytable_output->execute;

my %row1 = $mytable_ouput->fetchrow_hashref;

my @field_names = keys %row1;

# @field_names .



# . ,

my @row1 = values %row1;

DBI::finish

$result = $statement_handle->finish;

DBI:: finish , . . DBD::mSQL DBD::mysql , . undef, .



use DBI;

my $db = DBI->connect('DBI:mysql:mydata','me','mypassword');

my $query = "SELECT * FROM mytable";

my $mytable_output = $db->prepare($query);

$mytable_output->execute;

$mytable_output->finish;

# $mytable_output

# SQL.

DBI::func

$handlc->func(@func_argumcnts, $func_name);

@dbs = $db->func("$hostname", '_ListDBs');

@dbs = $db->func("$hostname:Sport", '_ListDBs');

@tables = $db->func('_ListTables');

$result = $drh->func( $database, '_CreateDB' );

Sresult = $drh->func( Sdatabase, '_DropDB' );

DBI::func , DBD. , . . , - . DBD::mSQL DBD::mysql :

_ListDBs

_ListDBs . DBJ::data_sources .

_ListTables

_ListTables , .



_CreateDB

_CreateDB . . -1 0 .

_DropDB

_DropDB . . . -1 0 .



use DBI;

my $db = DBI->connect('DBI:mysql:mydata','me','mypassword');

my @tables =.$db->func('List-Tables');

# @tables 'mydata'.

DBI::neat

$neat_string = DBI: :neat($s'tring);

$neat_string = DBI::neat($string, $maxlen);

DBI: : neat . . . . , , (...). , 400.



use DBI;

my $string = " , , . ";

my$neat_string = OBI: :neat($string,14);

# $neat_string : ' , ...

DBI::neat_list

$neat_string = DBI::neat_list(\@listref, $maxlen);

$neat_string = DBI::neat_list(\@listref, $maxlen, $field_seperator);

DBI: :neat_list , . . - . - , . OBI: :neat . . , .





use DBI;

my @list = (' Bob', 'Joe', 'Frank');

my $neat_string = DBI::neat_list(\@list, 3);

# $neat_string : 'Bob', 'Joe', 'Fra...

DBI::prepare

$statement_handle = $db->prepare($statement);

$statement_handle = $db->prepare($statement, \%unused);

DBI: :prepare SQL-, , DBI: : execute . DBD ( DBD::mSQL DBD::mysql) . mSQL MySQL , DBI: : prepare . '?'. - (placeholders). DBI: : bind_param -. - , undef.



use DBI;

my $db = DBI->connect('DBI:mysql:mydata','me','mypassword');

my $statement_handle = $db->prepare('SELECT * FROM mytable');

# .

My $statement_handle = $db->prepare('SELECT name, date FROM myothertable WHERE name like ?');

# # DBI::bind_param.

DBI::quote

$quoted_string = $db->quote($string);

DBI::quote SQL , .



use DBI;

my $db1 = DBI->connect('DBI:mSQL:mydata',undef,undef);

my $db2 = DBI->connect('DBI:mysql:myotherdata','me','mypassword');

my $string = "Sheldon's Cycle";

my $qs1 = $db1->quote($string);

# $qs1: 'Sheldon\'s Cycle' ( )

my $qs2 = $db2->quote($string);



# $qs2 : 'Sheldon's Cycle' ( )

#

# .

DBI::rows

$number_of_rows = $statement_handle->rows;

Del: : rows , . DBD::mSQL DBD::mysql , SELECT. , , , SELECT. . 1, - . $DBI: : rows .



use DBI;

my $db = DBI->connect('DBI:mSQL:mydata',undef,undef);

my $query = "SELECT name, date FROM myothertable WHERE name='Bob'";

my $myothertable_output = $db->prepare($query);

$myothertable_output->execute;

my $rows = $myotnertable_output->rows;

print " 'myothertable' $rows 'b'\n";

DBI::state

$sql_error = $handle->state;

DBI: : state SQL SQLSTATE DBI. DBD::mSQL DBD^mysql 'S1000' . . $1: : state .



Use OBI;

my $db = DBI->connect('DBI:mysql:mydata',

'webuser','super_secret_squirl');

my $sql_error = $db->state;

warn("BoT DBI SQL: $sql_error");

DBI::trace

DBI->trace($trace_level)

DBI->trace($trace_level, $trace_file)

$handle->trace($trace_level);

$handle->trace($trace_level, $trace_file);

DBI:: trace . 2, . 0 . DBI->trace , a $handle->trace - . DBI- >t race $handle->trace . , DBI_TRACE. ( 0 2), . 2, .





use DBI;

my $db1 = DBI->connect('DBI:mysql:mydata',

'webuser','super_secret_squirrel');

my $db2 = DBI->connect('DBI:mSQL:myotnerdata',undef,undef);

DBI >trace(2);

# 2.

$db2->trace(0);

# $db2, $db1

$db1->trace(2,'DBI.trace');

# 2,

# 'DBI.trace'.

DBI::commit, DBI::rollback, DBI::ping

$result = $db->commit;

$result = $db->rollback;

Sresult = $db->ping;

DBI: :commit DBI: : rollback , . DBD::mSQL DBD::mysql . DBD: :ping , . DBD::mSQL DBD::mysql .



$db->{AutoCommit}

$handle->{ChopBlanks}

$handle->{CompatMode}

$handle->{InactiveDestroy}

$handle->{LongReadLen}

$handle->{LongTruncOk}

$handle->{PrintError}

$handle->{RaiseError}

$handle->{Warn}

$statement_handle->{CursorName}

$statement_handle->{insertid} ( MySQL)

$statement_handle->{is_blob} ( MySQL)

$statement_handle->{is_key} ( MySQL)

$statement_handle->{is_not_null}

$statement_handle->{is_num}

$statement__handle->{is_pri_key} ( MySQL mSQL 1.x)

$statement_handle->{length}

$statement_handle->{max_length} ( MySQL)

$statement_handle->{NAME}

$statement_handle-><NULLABLE}

$statement_handle->{NUM_OF_FIELDS}

$statement_handle->{NUM_OF_PARAMS}

$statement_handle->{table}

$statement_handle->{type}

DBI.pm API , . . . 0 . . , , .



$db->{AutoCommit}

, . mSQL MySQL ( ). .

$handle->{ChopBlanks}

, (, DBI: : fetch row ). . - «».

$handle->{InactiveDestroy}

- (fork), . , . - «».

$handle-> {PrintError}

. $DBI: :errstr. . -«».

$handle->{RaiseError}

, , '__DIE__'. , , . -«».

$handle->{Warn}

( Perl 4). DBI, . (, , ) . «».

$statement_handle->{insertid}

, DBD::mysql. auto_increment ( ). auto_increment , undef.



$statement_handle->{is_blob}

, DBD::mysql. , , BLOB. , SELECT, $statement_handle->{is_blob} undef.

$statement_handle->{is_key}

, DBD::mysql. , , KEY. , SELECT, $statement_handle->{is_key} undef.

$statement_handle->{is_not_null}

, DBD::mSQL DBD::mysql. , , 'NOT NULL' . , SELECT, undef. , $statement_handle->{NULLABLE} .

$statement_handle->{is_num}

, DBD::mSQL DBD::mysql. , , . , SELECT, $statement_handle->{is_num} undef.

$statement_handle->{is_pri_key}

, DBD::mSQL DBD::mysql. DBD::mSQL mSQLl.x, mSQL2.x . , , .

, SELECT, undef.



$statement_handle->{length}

, DBD::mSQL DBD::mysql. , . , SELECT, $statement_handle->{length} undef.

$statement_handle->{max_length}

, DBD::mysql. , . , SELECT, undef.

$statement_handle->{NAME}

, . , SELECT, $statement_handle->{NAME} undef.

$statement_handle->{NULLABLE}

, , NULL. , 'NOT NULL', 0. 1. , SELECT, undef.

$statement_handle->{NUM_OF_FIELDS}

, . , SELECT, $statement_handle->{NUM_OF_FIELDS} 0.

$statement_handle->{NUM_OF_PARAMS}

- . - '?'. - DBI: : bind_values .

$statement_handle->{table}

, DBD::mSQL DBD::mysql. , . SELECT .



$statement_handle->{type}

, DBD::mSQL DBD::mysql. , . , SELECT, $statement_handle->{max_length} undef. , mysql_com.h MySQL. DBI . &Mysql: : FIELD_TYPE_ * Mysql.pm. DBD::mysql $statement_handle->{format_type_name} , $statement_handle- >{type} , , SQL- . , , DBD::niysql , DBI .

$statement_handle->{CursorName}

$handle->{l_ongReadLen}

$handle->{l_ongTruncOk}

$handle->{CompatMode}

DBD::mSQL DBD::mysql. , 0 undef. $statement_handle->{CursorName} . «» .



use DBI;

my $db = DBI->connect('mysql:mydata','me','mypassword');

$db->{RAISE_ERROR} = 1;

# DBI/DBD .

my $statement_handle = $db->prepare('SELECT * FROM mytable');

$statement_handle->execute;

my @fields = @{$statement_handle->{NAME}};

# @fields 'mytable'.




Msql.pm API


use Msql

use Msql;

Perl, Msql.pm.

Msql::connect

$db = Msql->connect;

$db = Msql->connect($host);

$db = Msql->connect($host, Sdatabase);

Perl Msql. . Unix Msql . . , IP- mSQL. . , mSQL, - . . , (database handle). . , undef, $Msql: :db_errstr .


use Msql;

# Unix ' my $db = Msql->connect;

# ...

# 'www.myserver.com' ,

m $db = Msql->connect('www.myserver.com');

# ...

# 'www.myserver.com' 'mydata'

m $db = Msql->connect('www.myserver.com','mydata');

Msql::createdb

$result = $db->createdb($database);

Msql: : createdb , . mSQL. , CGT-. CGI , . -1 0 .


use Msql;


my $db = Msql->connect;

my $my_new_database = 'mynewdata';

my $result = $db->createdb($my_new_database);

die " !"

if $result == -1;

print "$my_new_database .\n";

Msql::database

$database = $db->database;

Msql: database . undef, .



use Msql;

my $db = Msql->connect('www.myserver.com','mydata');

my $database = $db->database;

print " 'mydata': $database\n";

Msql::dropdb

$result = $db->dropdb($database);

Msql: :dropdb , . mSQL. , CGI-. CGI , . -1 0 . , , .



use Msql;

my $db = Msql->connect;

my $result = $db->dropdb('mydata');

die " !"

if result == -1;

print "'mydata' .\n";

Msql::errmsg

$error = $db->errmsg:

Msql::errmsg mSQL. , , . , undef.



use Msql;

my $db = Msql->connect;

my Serror = $db->errmsg;

warn(" mSQL: $error");

Msql::getsequenceinfo

($step, $value) = $db->getsequenceinfo($table);

Msql: :getsequenceinfo . , . , undef, Msql: :errmsg .





use Msql;

my $db = Msql->connect;

my ($step, $value) = $db->getsequenceinfo('mytable');

die " B mytable " if not $step;

print "B mytable $value

$step\n";

Msql::host

Shost = $db->host;

Msql: :host . . , , Msql:: host , Msql::connect . , Msql:: host undef, Msql: : connect .



use Msql;

my $ijh - Msql->connect( 'www.myserver.com');

my $host = $db->host;

print ", 'www.myserver.com': $host\n";

Msql::listdbs

@databases = $db->listdbs;

Msql: :listdbs . , .



use Msql;

my $db = Msql->connect;

my @databases = $db->listdbs;

print " :\n\n" . join("\n",@databases);

Msql::listfields

$fields = $db->listfields($table);

Msql:: listf ields . , . (statement handle). Msql::Statement: :as_string, Msql::Statement: :listindices ( mSQL2.0), Msql: Statement: :numfields , Msql::Statement::table , Msql::Statement::name , Msql::Statement::type , Msql::Statement::isnotnull , Msql::Statement::isprikey , Hsql::Statement::isnum Msql::Statement: .'length . , undef, Msql: :errmsg . Msql: :Statement: :fetchhash , .





use Msql;

my $db = Msql->connect;

$db->selectdb('mydata');

my $fields = $db->listfields('mytable');

warn (" 'mytable-': " . $db->errmsg)

if (not $fields);

# $ fields 'mytable'.

print "mytable :\n";

print $fields->as_string;

Msql::listindex

@index_handles = $db->listindex($table,$index);

Msql: : listindex , . , , , . , , . , Msql::query , . , undef. «Index». , mSQL2.0 «avl». , . mSQL 2.0 .



use Msql;

my $db = Msql->connect;

$db->selectdb('mydata');

my $mytable_fields = $db->listfields('mytable');

my @indices = $mytable_fields->listindices;

# .

foreach (@indices) {

my $index_info_handle = $db->listindex('mytable',$_);

my (@index_info) = $index_info_handle->fetchcol(0);

my $type_of_index = shift(@index_info);

# $type_of_index (, 'avl'),

# a @index_info .

Msql::listtables

@tables = $db->listtables;

Msql: :listtables , . , .



use Msql;

my $db = Msql->connect;



my @tables = $db->listtables;

my $database = $db->database;

print "B $database :\n\n" join("\n",@tables);

Msql::query

$query_output = $db->query($sql_statement);

Msql::query Msql.pm API. SQL- . , SQL-. SELECT, , . , . , Msql:: listf ields ( Msql:: Statement:: listindices ), a : Msql::Statement: :fetchrow , Msql::Statement::fetched , Msql::Statement::fetchhash , Msql: Statement::numrows , Msql::Statement::maxlength Msql: Statement: :dataseek . - , undef Msql: :errmsg . , , .



use Msql;

my $db = Msql->connect; $db->selectdb('mydata');

my $query1 = "SELECT * FROM mytable";

my $query2 = "SELECT name, date FROM myothertable WHERE name LIKE 'Bob%'";

my $query3 = "UPDATE myothertable SET name='Bob' WHERE name='Joe'";

my $mytable_output = $db->query($query1);

my $myothertable_output = $db->query($query2);

my $myothertable_input = $db->query($query3);

# $mytable_output 'mytable'

# $myothertable_output 'myothertable'

print " 'myothertable' $myothertable_input

\n";

$Msql::QUIET

$Msql: : QUIET true, -w Perl . MsqlPerl STDERR. . -w , $Msql: : QUIET .





use Msql;

# . ,

# '-w'.

$Msql::QUIET = 1;

# ...

# . $Msql::QUIET = undef;

Msql::quote

$quoted_string = $db->quote($string);

$truncated_quoted_string = $db->quote($string,$length);

Msql: :quote . , , CHAR TEXT. , , « ». , .



use Msql;

my $db = Msql->connect;

my $string = " ' ( )";

my $qstring = $db->quote($string);

print qq%Tenepb "'\\' ( )'" : $qstring\n%;

Msql::selectdb

$db->selectdb($database);

Msql: :selectdb . Msql: :errmsg . - $db->database , . .



use Msql;

my $db = Msql->connect;

$db->selectdb('mydata');

# 'mydata'

if ($db->database ne 'mydata') {

wrn(' !'); }

$db->selectdb('myotherdata');

# 'myotherdata'

Msql::shutdown

$result = $db->shutdown;

Msql: : shutdown mSQL . , , CGI- , . -1 0 .





use Msql;

my $db = Msql->connect;

# ...

my $result = $db->shutdown;

die " !" if $result -1;

print " .\n";

Msql::Statement::as_string

$formatted_table = $statement_handle->as_string;

Msq1: :Statement: :as_string , , ASCII. , msql. pmsql, Msql.pm, .



use Msql;

my $db = Msql->connect;

$db->selectdb('mydata');

my $query = "SELECT * FROM mytable";

my $mytable_output = $db->query($query);

print " :\n", $mytable_output->as_string;

# ,

# Msql:[Statement:ifetchhash.

Msql::Statement::dataseek

$statement_handle->dataseek($row_number);

Msql: :Statement: :dataseek . , Msql: :Statement: :fetchrow Msql: Statement: :fetchhash . , undef. 0.



use Msql;

my $db = Msql->connect;

$db->selectdb('mydata');

my Squery = "SELECT name, date FROM myothertable";

my $myothertable_output = $db->query($query);

my @names = $myothertable_output->fetchcol(0);

my @dates = $myothertable_output->fetchcol(1);

# .

$myothertable_output->dataseek(0);

# ,

print " : ", $myothertable_output->fetchrow, "\n".

Msql::Statement::fetchcol



@column_of_data = $statement_handle->fetchcol($column_number);

Msql: :Statement: :fetched , . , . 0. , , , Msql::Statement: :dataseek . , undef.



use Msql;

my $db = Msql->connect;

$db->selectdb('mydata');

my $query = "SELECT name, date FROM myothertable WHERE name LIKE 'Bob%'";

my $myothertable_output = $db->query($query);

my @names = $myothertable_output->fetchcor(0);

# @names .

my @dates = $myothertable_output->fetchcol(1);

# ©dates .

for (0..$#names) {

print "Row $_: $names[$_], $dates[$_]\n"; }

Msql::Statement::fetchhash

%hash ='$statement_handle->fetchhash;

Msql::Statement: :fetchhash ( ). , - . . , undef.



use Msql;

my $db = Msql->connect;

$db->selectdb('mydata');

my $query = "SELECT * FROM mytable";

my $mytable_output = $db->query($query);

my %first_data_row = $mytable_output->fetchhash;

my @fields = keys %first_data_row;

# @fields . ,

# Msql::listfields,

If ,



# Msql::query.

my (%data_row);

print ]oin("", ©fields), "\n';

print "-"x70;

print join("", values(%first_data_row);

print join("", values(%data_row)) while %data_row = $mytable_output-

>fetchhash;

# ,

# .

Msql::Statement::fetchrow

@row_of_data = $statement_handle->fetch row;

Msql:: Statement: : fetch row , Msql:.-query. Msql: Statement: :fetchrow . , undef. . SELECT*FROM ... , .



use Msql;

my $db = Msql->connect;

$db->selectdb('mydata');

my $query1 = "SELECT * FROM mytable";

my $query2 = "SELECT name, date FROM myothertable WHERE name LIKE

'Bob%'";

my $mytable_output = $db->query($query1);

my $myothertable_output = $db->query($query2);

my $i = 0;

# ,

# .

while (my(@mytable_rows)=$mytable_output->fetcnrow) {

print " ",$i++,": ".join(', ',@mytable_rows)."\n";

# 'mytable',

# @mytable_rows .

}

my (Sname, $date);

# $myotrertable_output.

($name, $datc) = $myothertaPle_output->fetchrow;

# ...

($name, $date) = $myothertable_output->fetchrow;

# ...

my @name_and_date = $myothertable_output->fetchrbw;

# .....

Msql::Statement::isnotnull

@not_null = $statement_handle->isnotnull;

Msql:: Statement: :isnotnull , , 'NOT NULL'. .





use Msql;

my $db = Msql->connect;

$db->selectdb('mydata');

my Soutput = $db->query("select * from mydata");

my @names = $output->name;

my @not_null = $output->isnotnull;

for (0..$#not_null) {

print "$names[$_] null\n"

if $not_null[$_]; }

Msql::Statement::isnum

@numbers = $statement_handle->isnum;

Msql: : Statement: : isnum , , . . «» , , 'INT' 'REAL', 'CHAR' 'TEXT'.



use Msql;

my $db = Msql->connect;

$db->selectdb('mydata');

my $output = $dD->query("select name, date from myothertable");

print "Name "

if $output->isnum->[0];

print "Date "

if $output->isnum->[1];

Msql::Statement::isprikey

@primary_key = $statement_handle->isprikey;

Msq1::Statement: :isprikey , , . . , , mSQL 2, mSQL 2 . mSQL 1, .



use Msql;

my $db = Msql->connect;

$db->selectdb('mydata');

my $output-= $db->query("select * from mytable");

my @prikeys = $output->isprikey;

my $number_of_prikeys = scalar @prikeys;

print " $number_of_prikeys . ",

" , ".

" \n";



Msql::Statement::length

@lengths = $statement_handle->length;

Msql::Statement:: length , . , . .



use Msql;

my $db = Msql->connect;

$db->selectdb('mydata');

my $output = $db->query("select- * from mytable");

my @types = $output->type;

my @lengths = $output->length;

for (0..$#types) {

if ($types[$_] == &Msql: :CHAR_TYPE and $lengths[$_] > 1000000) {

print " - CHAR!\";

} }

Msql::Statement::listindices

Pindices = $statement_handle->listindices;

Msql: : Statement: :listindices , - . , , Msql: : listf ields . , undef. mSQL 2.0 .



use Msql;

my $db = Msql->connect;

$db->selectdb('mydata');

my $mytable_fields = $db->listfields('mytable');

my ©indices = $mytable_fields->listindices;

print "B 'mytable' : " . join(", ",@indices) .

"\n;

Msql::Statement::maxlength

@max_lengths = $statement_handle->maxlength; '

Msql::Statement: :maxlength . . mSQL , . mSQL , .



use Msql;

$db = Msql->connect;



$db->selectdb('mydata');

my Soutput = $db->query('select name, date from myothertable');

print " " . $ouput->maxlength->[0] . " ,\n";

Msql::Statement::name

@column_names = $statement_handle->name;

Msql:: Statement:: name , . . Msql::Statement::table , ( ) Msql::Statement::numfields



use Msql;

my $db = Msql->connect;

$db->selectdb('mydata');

my $output = $db->query("select * from mytable");

my @column_names = $output->names;

# @column_names - 'mytable'

Msql::Statement::numfields

$number_of_fields = $statement_handle->numfields;

Msql:: Statement: : numf ields , . , .



use Msql;

my $db = Msql->connect;

$db->selectdb('mydata');

my $output = $db->query("select * from mytable");

my $numfields = $output->numfields;

my $numrows = $output->numrows;

print " 'mytable' $numfields \n";

print " Snumrows . 'mytable'\n";

print "" . ($numfields*$numrows) . " .\n";

Msql::Statement::numrows

$number_of_rows = $statement_handle->numrows;

Msql: : Statement: : numrows , . , , , Msql: :listfields , 'N/A.' , - , SELECT, , - 0.





use Msql;

my $db = Msql->connect;

$db->selectdb('mydata');

my Soutput = $db->query("select * from mytable");

my $numrows = '$output->numrows;

print "B 'mytable' $numrows \n";

Msql::Statement::table

@tables = $statement_handle->table;

Msql: :Statement: : table , , . (. Msql: : Statement: : isnum .) , . , , $statement_handle->table , $statement_handle->numfields .



use Msql;

my $db = Msql->connect;

$db->selectdb('mydata');

my Soutput = $db->query('select myothertable. name, myothertable.date,

mythirdtable. name from myothertable, mythirdtable where myothertable. name

= mythirdtable. name');

my @tables = $output->table;

# @tables ('myothertable', 'myothertable', 'mythirdtable')

Msql::Statement::type

@column_types = $statement_handle->type;

Msql: : Statement: : type , . . ( ), , Msql.pm, &Msql: : CHAR_TYPE &Msql: : INT_TYPE. - , . 10 «Perl». .



use Msql;

my $db = Msql->connect;

$db->selectdb('mydata');

my $output = $db->query("select name, date from myothertable");



my ($name_type, $date_type) = $output->type;

for ($name_type) {

$_ eq &Msql: :CHAR_TYPE and do {

print ''name CHAR';

last;

} $_ eq &Msql::INT_TYPE and do {

print 'name INT'; last; } # .....

}

# $date_type

Msql::sock

$sock = $db->sock;

Msql:: sock , , mSQL. .



use Msql;

my $db = Msql->connect;

my $sock = $db->sock;

print " $sock.\n";

Msql::*_TYPE

Msql.pm , mSQL:

&Msql::CHAR_TYPE &Msql::INT_TYPE &Msql::REAL_TYPE &Msql::IDENT_TYPE

&Msql::TEXT_TYPE &Msql::IDX_TYPE &Msql::NULL_TYPE &Msql::DATE_TYPE

&Msql::UINT_TYPE &Msql::MONEY_TYPE &Msql::TIME_TYPE &Msql::SYSVAR_TYPE



use Msql;

%types = (

'CHAR' => &Msql::GHAR_TYPE, 'INT' => &Msql::INT_TYPE, 'REAL' => &Msql::REAL_TYPE, 'SYSVAR' => &Msql::SYSVAR_TYPE, 'TIME' => &Msql::TIME_TYPE, 'MONEY' => &Msql::MONEY_TYPE, 'UINT' => &Msql::UINT_TYPE, 'TEXT' => &Msql::TEXT_TYPE, 'NULL' => &Msql::NULL_TYPE, 'DATE' => &Msql::DATE_TYPE, 'IDENT' => &Msql::IDENT_TYPE, 'IDX' => &Msql::IDX_TYPE,

);

# $types{'CHAR'}

# &Msql::CHAR_TYPE. %types

# , keys() values().

$Msql::VERSION

$Msql:: VERSION Msql.pm.



use Msql;

print " Msql.pm $Msql::VERSION.\n";




Mysql.pm API


Mysql.pm API Msql API ( «Msql» «Mysql»), :

Mysql::connect

$db = Mysql->connect($host, Sdatabase, $user, $password);

, Msql: :connect , Mysql:: connect , . - IP- MySQL. undef, Unix . . Mysql: :selectdb . undef , . . MySQL. .


use Mysql;

$db = Mysql->connect(undef,'mydata','webuser1, 'super_secret_squirrel');

# MySQL

# 'mydata1.

# 'webuser'

# 'super_secret_squirrel'.

Mysql::errno

$error_number = $db->errno;

Mysql: :errno . , Msql: : errmsg .


use Mysql;

my $db = Mysql->connect(undef,'mydata','webuser', 'super_secret_squirrel');

# ...

my $output = $db->query( 'SELECT * from mydata');

if (not $output) {

print " " . $output->errno . ": " . $output->errfnsg . "\n"; }

Mysql::FIELD_TYPE_*

Mysql: :TYPE_ *, Msql::TYPE *, Mysql.pm :

&Mysql::FIELD_TYPE_BLOB &Mysql::FIELD_TYPE_CHAR &Mysql::FIELD_TYPE_DECIMAL &Mysql::FIELD_TYPE_DATE &Mysql::FIELD_TYPE_DATETIME &Mysql::FIELD_TYPEJ)OUBLE &Mysql::FIELD_TYPE_FLOAT &Mysql: : FIELD_TYPE_INT24 &Mysql::FIELD_TYPE_LONGLONG &Mysql::FIELD_TYPE_LONG_BLOB &Mysql::FIELD_TYPE_LONG &Mysql::FIELD_TYPE_MEDIUM_BLOB &Mysql::FIELD_TYPE_NULL &Mysql::FIELD_TYPE_SHORT &Mysql::FIELD_TYPE_STRING &Mysql::FIELD_TYPE_TIME &Mysql::FIELD_TYPE_TIMESTAMP &Mysql::FIELD_TYPE_TINY_BLOB &Mysql::FIELD_TYPE_VAR_STRING




use Mysql;

my $db = Mysql->connect(undef, 'mydata');

my Soutput = $db->query("SELECT name, data from myothertable");

if ($output->type->[0] = &Mysql::FIELD_TYPE_STRING) {

print "Name STRING.\n"; }

Mysql::Statement::affectedrows

$number_of_affected_rows = $statement^handle->affectedrows;

Msql: :Statement: : affectedrows , . , Mysql.pm , SELECT.



use Mysql;

my $db = Mysql->connect(undef,'mydata');

my $output = $db->query("UPDATE mytable set name='bob' where

name='joe'");

print $output->affectedrows . " .\n";

Mysql::Statement::info

$info = $sth->info;

Mysql: : Statement:: info , Mysql.pm , ALTER TABLE LOAD DATA INFILE . , LOAD DATA INFILE Mysql: : Statement:: info , , , .



use Mysql;

$db = Mysql->connect(undef,'mydata');

my $output = $db->query("LOAD DATA INFILE 'mydata.dat' INTO TABLE mytable");

my $info = $output->info($output);

print « LOAD DATA: $info\n»;

Mysql::Statement::insertid

$new_id = $statement_handle->insertid;

Mysql::Statement::insertid auto_increment ( ) . auto_increment , undef.



use Mysql;

my $db = Mysql->connect(undef,'mydata');

my $output = $db->query(

"INSERT into mytable (id, name, date) VALUES ('','bob', 'today')";

my $new_id = $output->insertid;

print "Bob ID, $new_id.\n";



mSQL MySQL DataBase Dependent/DataBase Independent (DBI/DBD) MsqlPerl MysqlPerl :

Perl 5

Perl 5. Perl 5.005_02. Perl 5.004, , . Perl, , : http://www.perl.com.

DBI

DBI/DBD Comprehensive Perl Archive Network (CPAN). DBI-0.90. http://www.perl.com/CPAN/authors/id/TIMB/DBI/DBI-l.06.tar.gz.

Data::ShowTable

Data::ShowTable . Msql-Mysql. - Data-ShowTable-., : http://www.perl.com/CPAN/authors/id/AKSTE/Data-ShowTable-3.3.tar.gz.

mSQL / MySQL

3 «» , mSQL MySQL.


MsqlPerl MysqlPerl ANSI- , , make, Id . . , Perl. , GNU ftp://ftp.gnu.org/pub/gnu/.

Msql-Mysql (Jochen Wiedmann), ID CPAN JWIED. Msql-Mysql http://www.perl.com/ authors/id/ JWIED. Msql-Mysql-modules-1.2017.tar.gz.

:

tar xvzf Msql-Mysql-modules-1.2017.tar.gz

cd Msql-Mysql-modules-1.2017


INSTALL, . Makefile.PL:

perl Makefile.PL

, mSQL, MySQL . .

mSQL. , lib include, mSQL. /usr/local /Hughes, , /usr/local /usr/local/Minerva.

MySQL. mSQL, , lib include, - /usr/local. , , .

make- . make .

make

Perl, mSQL / MySQL, make . , , - .

make test

, . . . ok. , .

make install

Perl. , ( /usr/local/bin /usr/bin), pmsql, pmysql dbimon.