Operations related to databases are often used. It includes connection codes, SQL commands, etc., but I have never deliberately remembered them (I don’t want to remember this thing), so I often check the books and flip through them when I use them. Some less used databases may not be found smoothly, so now I will summarize them here for your reference. (If personal level is limited, you are welcome to correct any defects.)
<I>. Database connection method:
DSN-less connection method of database:
set adocon=("")
"Driver={Microsoft Access Driver(*.mdb)};DBQ="& _
("Path where the database resides")
OLE DB connection method:
set adocon=("")
"Provider=.4.0;"& _
"Data Source=" & ("Path where the database is located")
Server connection method:
set adocon=("")
"Driver={SQL Server};Server=(Local);UID=***;PWD=***;"& _
"database=database name;"
server OLE DB connection method:
set adocon=("")
"provider=SQLOLEDB.1;Data Source=RITANT4;"& _
"user ID=***;Password=***;"& _
"initial Catalog=database name"
Connection method:
set adocon=("")
"Driver={microsoft odbc for oracle};server=;uid=admin;pwd=pass;"
OLE DB Connection method:
set adocon=("")
"Provider=;data source=dbname;user id=admin;password=pass;"
Connection method:
set adocon=("")
"Driver={microsoft dbase driver(*.dbf)};driverid=277;dbq=------------;"
Connection method:
set adocon=("")
"Driver={mysql};database=yourdatabase;uid=username;pwd=yourpassword;option=16386;"
Foxpro Connection method:
set adocon=("")
"Driver={microsoft Visual Foxpro driver};sourcetype=DBC;sourceDB=*.dbc;Exclusive=No;"
text Connection method:
set adocon=("")
"Driver={microsoft text driver(*.txt; *.csv)};dbq=-----;"&_
"extensions=asc,csv,tab,txt;Persist SecurityInfo=false;"
text OLE DB Connection method:
set adocon=("")
"Provider=.4.0;data source=your_path;"&_
"Extended Properties'text;FMT=Delimited'"
<two>. Four commonly used SQL commands:
1. Query data records (Select)
Syntax: Select Field Serial From table Where Field=Content
Example: If you want to find all records whose author is "cancer" from the book table, the SQL statement is as follows:
select * from book where author='cancer'
"*" is to take out all fields in the book table. If the field value of the query is a number, the subsequent "content" does not need to be added with single quotes.
If this is a date, use (#) to include in Access, and use (') to include in SQL server.
like:
select * from book where id=1
select * from book where pub_date=#2002-1-7# (Access)
select * from book where pub_date='2002-1-7' (SQL Server)
hint:
The date function to_date is not a standard SQL article, and not all databases are applicable, so when you use it, you should refer to the specific database syntax.
<I>. Database connection method:
DSN-less connection method of database:
set adocon=("")
"Driver={Microsoft Access Driver(*.mdb)};DBQ="& _
("Path where the database resides")
OLE DB connection method:
set adocon=("")
"Provider=.4.0;"& _
"Data Source=" & ("Path where the database is located")
Server connection method:
set adocon=("")
"Driver={SQL Server};Server=(Local);UID=***;PWD=***;"& _
"database=database name;"
server OLE DB connection method:
set adocon=("")
"provider=SQLOLEDB.1;Data Source=RITANT4;"& _
"user ID=***;Password=***;"& _
"initial Catalog=database name"
Connection method:
set adocon=("")
"Driver={microsoft odbc for oracle};server=;uid=admin;pwd=pass;"
OLE DB Connection method:
set adocon=("")
"Provider=;data source=dbname;user id=admin;password=pass;"
Connection method:
set adocon=("")
"Driver={microsoft dbase driver(*.dbf)};driverid=277;dbq=------------;"
Connection method:
set adocon=("")
"Driver={mysql};database=yourdatabase;uid=username;pwd=yourpassword;option=16386;"
Foxpro Connection method:
set adocon=("")
"Driver={microsoft Visual Foxpro driver};sourcetype=DBC;sourceDB=*.dbc;Exclusive=No;"
text Connection method:
set adocon=("")
"Driver={microsoft text driver(*.txt; *.csv)};dbq=-----;"&_
"extensions=asc,csv,tab,txt;Persist SecurityInfo=false;"
text OLE DB Connection method:
set adocon=("")
"Provider=.4.0;data source=your_path;"&_
"Extended Properties'text;FMT=Delimited'"
<two>. Four commonly used SQL commands:
1. Query data records (Select)
Syntax: Select Field Serial From table Where Field=Content
Example: If you want to find all records whose author is "cancer" from the book table, the SQL statement is as follows:
select * from book where author='cancer'
"*" is to take out all fields in the book table. If the field value of the query is a number, the subsequent "content" does not need to be added with single quotes.
If this is a date, use (#) to include in Access, and use (') to include in SQL server.
like:
select * from book where id=1
select * from book where pub_date=#2002-1-7# (Access)
select * from book where pub_date='2002-1-7' (SQL Server)
hint:
The date function to_date is not a standard SQL article, and not all databases are applicable, so when you use it, you should refer to the specific database syntax.
12Next pageRead the full text