PHP Mysql参考手册
mysql8 参考手册
mysql8 参考手册
《MySQL 8 参考手册》是一套详细介绍MySQL 8 最新版功能的中文文档,其中包含了官方最新版英文文档,方便用户学习和查询。
手册中详细介绍了MySQL 的使用方法、查询方法、函数、ODBC 等方面的内容,为用户提供了全面的 MySQL 8 知识和技术支持。
该手册涵盖了 MySQL 8 的各个方面,包括 SQL 语句、数据类型、索引、
视图、存储过程、触发器等,以及 MySQL 8 的新特性,如窗口函数、JSON 支持、数据字典等。
用户可以按照章节和知识点,逐步学习 MySQL
8 的各项功能和操作,掌握数据库管理的最佳实践和技巧。
此外,该手册还提供了丰富的示例和案例,帮助用户更好地理解和应用所学知识。
同时,手册中还包含了 MySQL 8 的性能优化、安全设置等方面的内容,为用户在实际应用中提供了实用的指导。
总之,《MySQL 8 参考手册》是一本全面介绍 MySQL 8 的书籍,适合数
据库管理员、开发人员以及需要了解和使用 MySQL 的用户阅读和使用。
MySQL中文参考手册MySQL学习总结-MySQL-API函数描述
MySQL函数描述、学习总结(适用版本:MySQL 3.23.7alpla)1. MySQL API (2)1.1. MySQL C API (2)1.2. C API数据类型 (3)1.3. C API函数概述 (6)1.4. C API函数描述 (9)1.4.1. mysql_affected_rows() (10)1.4.2. mysql_close() (11)1.4.3. mysql_connect() (11)1.4.4. mysql_change_user() (12)1.4.5. mysql_create_db() (13)1.4.6. mysql_data_seek() (14)1.4.7. mysql_debug() (15)1.4.8. mysql_drop_db() (15)1.4.9. mysql_dump_debug_info() (16)1.4.10. mysql_eof() (17)1.4.11. mysql_errno() (18)1.4.12. mysql_error() (19)1.4.13. mysql_escape_string() (20)1.4.14. mysql_fetch_field() (21)1.4.15. mysql_fetch_fields() (22)1.4.16. mysql_fetch_field_direct() (23)1.4.17. mysql_fetch_lengths() (23)1.4.18. mysql_fetch_row() (24)1.4.19. mysql_field_count() (26)1.4.20. mysql_field_seek() (27)1.4.21. mysql_field_tell() (28)1.4.22. mysql_free_result() (28)1.4.23. mysql_get_client_info() (29)1.4.24. mysql_get_host_info() (29)1.4.25. mysql_get_proto_info() (30)1.4.26. mysql_get_server_info() (30)1.4.27. mysql_info() (30)1.4.28. mysql_init() (31)1.4.29. mysql_insert_id() (32)1.4.30. mysql_kill() (32)1.4.31. mysql_list_dbs() (33)1.4.32. mysql_list_fields() (34)1.4.33. mysql_list_processes() (35)1.4.34. mysql_list_tables() (35)1.4.35. mysql_num_fields() (36)1.4.36. mysql_num_rows() (38)1.4.37. mysql_options() (38)1.4.38. mysql_ping() (40)1.4.39. mysql_query() (41)1.4.40. mysql_real_connect() (41)1.4.41. mysql_real_query() (43)1.4.42. mysql_reload() (44)1.4.43. mysql_row_seek() (45)1.4.44. mysql_row_tell() (45)1.4.45. mysql_select_db() (46)1.4.46. mysql_shutdown() (47)1.4.47. mysql_stat() (47)1.4.48. mysql_store_result() (48)1.4.49. mysql_thread_id() (49)1.4.50. mysql_use_result() (50)1.4.51. 为什么在mysql_query()返回成功后,mysql_store_result()有时返回NULL? (51)1.4.52. 我能从查询中得到什么结果? (51)1.4.53. 我怎样能得到最后插入的行的唯一ID? (52)1.MySQL API1.1. MySQL C APIC API代码是随MySQL分发的,它被包含在mysqlclient库且允许C程序存取一个数据库。
php数据库,mysql字段类型,字段属性详解
本文由lchengm贡献 doc1。
MySQL 字段类型详解 MySQL 提 供 了 整 数 和 浮 点 数 的 数 值 类 型 。
可 根 据 所 要 表 示 的 值 的 范 围 选 择 相 应 的 类 型 。
对 于 整 数 类 型 , 如 果 指 定 了 AUTO_INCREMENT 属 性 , 则 列 必 须 为 PRIMARY KEY 或 UNIQUE 索 引 。
将 NULL 插 入 AUTO_INCREMENT 列 将 会 插 入 一 个 大 于 该 列 中 当 前 最 大 值 的 值 。
如 果 指 定 了 UNSIGNED 属 性 , 则 相 应 的 整 数 类 型 不 允 许 取 负 值 。
如 果 指 定 了 ZEROFILL 属 性 , 则 用 前 导 零 填 充 数 值 类 型 值 以 达 到 列 的 显 示 宽 度 。
1. TINYINT[(M)] 说明:非常小的整数 允 许 的 属 性 : AUTO _ I N C R E M E N T, UNSIGNED, ZEROFILL 取 值 范 围 : - 128 到 127( - 27 到 27- 1) 或 者 如 果 为 U N S I G N E D, 则 0 到 2 5 5 , ( 0 到 2 8-1) 缺 省 值 : 如 果 列 可 为 NULL; 则 为 NULL; 如 果 列 为 NOT NULL, 则 为 0 存储需求:1 字节 2. SMALLINT[(M)] 说明:小整数 允 许 的 属 性 : AUTO _ I N C R E M E N T, UNSIGNED, ZEROFILL 取 值 范 围 : - 32768 到 3 27 6 7( - 215 到 215- 1) 或 者 如 果 为 U N S I G N E D, 则 , 0 到 6 5 5 3 5( 0 到 216- 1) 缺 省 值 : 如 果 列 可 为 NULL; 则 为 NULL; 如 果 列 为 NOT NULL, 则 为 0 存储需求:2 字节 3. MEDIUMINT[(M)] 说明:中等大小的整数 允 许 的 属 性 : AUTO _ I N C R E M E N T, UNSIGNED, ZEROFILL 取 值 范 围 : -8388608 到 8 3 8 8 6 07( - 22 3 到 22 3- 1) 或 者 如 果 为 U N S I G N E , D, 则 0 到 16 7 7 2 15( 0 到 22 4- 1) 缺 省 值 : 如 果 列 可 为 NULL, 则 为 NULL; 如 果 列 为 NOT NULL, 则 为 0 存储需求:4 字节 4. INT[(M)] 说明:标准大小的整数 允 许 的 属 性 : AUTO _ I N C R E M E N T, UNSIGNED, ZEROFILL 取 值 范 围 : - 2147483648 到 2 14 7 4 8 3 6 4 7( - 231 到 2 3 1- 1) 或 者 如 果 为 U N , S I G N E D, 则 0 到 4 2 9 4 9 6 7 2 9 5( 0 到 2 3 2- 1) 缺 省 值 : 如 果 列 为 NULL, 则 为 NULL; 如 果 列 为 NOT FULL, 则 为 0 存储需求:4 字节 同 义 词 : I N T E G E R [(M)] 5. BIGINT[(M)] 说明:大整数 允 许 的 属 性 : AUTO _ I N C R E M E N T, UNSIGNED, ZEROFILL 取 值 范 围 : - 9223372036854775808 到 9 2 2 3 3 7 2 0 3 6 8 5 4 7 7 5 8 07( - 263 到 2 6 3- 1) 或 者 如 果 为 U N S I G N E D, 则 0 到 18 4 4 6 7 4 4 07 3 7 0 9 5 5 16 , 15( 0 到 26 4 -1) 缺 省 值 : 如 果 列 可 为 NULL, 则 为 NULL; 如 果 列 为 NOT NULL, 则 为 0 存储需求:8 字节 6. FLOAT [(M, D)] 说 明 : 小 浮 点 数 ; 单 精 度 ( 精 度 小 于 D O U B L E) 允许的属性:Z E R O F I L L 取 值 范 围 : 最 小 非 零 值 为 ±1.75494351E -38; 最 大 非 零 值 为 ±3 . 4 0 2 8 2 3 4 6 6 E + 3 8 缺 省 值 : 如 果 列 可 为 NULL, 则 为 NULL; 如 果 列 为 NOT NULL, 则 为 0 存储需求:4 字节 同 义 词 : MySQL3.23 版 以 前 , FLOAT(4) 为 具 有 缺 省 M 和 D 值 的 FLOAT 的 同 义 词 。
MySQL中文参考手册
MySQL中⽂参考⼿册1 MySQL 的⼀般信息这是MySQL参考⼿册;它记载了MySQL版本3.23.7-alpha。
MySQL 是⼀个快速、多线程、多⽤户和强壮的SQL数据库服务器。
对Unix和 OS/2 平台,MySQL基本上是免费的;但对微软平台,你在30 天的试⽤期后必须获得⼀个MySQL 许可证。
详见。
提供有关MySQL的最新信息。
对于MySQL能⼒的讨论,详见。
对于安装指南,见。
对于有关移植MySQL到新机器或操作系统的技巧,参见。
有关从 3.21 版升级的信息,详见。
MySQL的⼊门教程,见。
SQL和基准信息的例⼦,见基准⽬录(在分发中的'sql-bench'⽬录)。
对于新特征和错误修复⼀个历史记录,见。
对于当前已知错误和功能缺陷的⼀张列表,见。
未来计划,见。
这个计划的所有贡献者的名单,见。
重要:将臭⾍(错误)报告、问提和建议发到邮件列表(原⽂未提供)。
对源代码分发,mysqlbug 脚本可在‘scripts’⽬录下找到。
对⼆进制的分发,mysqlbug可在‘bin’⽬录下找到。
如果你有任何关于这本⼿册的增补或修正的任何建议,请将它们发给⼿册⼩组()。
1.1 什么是 MySQL?MySQL是⼀个真正的多⽤户、多线程SQL数据库服务器。
SQL(结构化查询语⾔)是世界上最流⾏的和标准化的数据库语⾔。
MySQL是以⼀个客户机/服务器结构的实现,它由⼀个服务器守护程序mysqld和很多不同的客户程序和库组成。
SQL是⼀种标准化的语⾔,它使得存储、更新和存取信息更容易。
例如,你能⽤SQL语⾔为⼀个⽹站检索产品信息及存储顾客信息,同时MySQL也⾜够快和灵活以允许你存储记录⽂件和图像。
MySQL 主要⽬标是快速、健壮和易⽤。
最初是因为我们需要这样⼀个SQL服务器,它能处理与任何可不昂贵硬件平台上提供数据库的⼚家在⼀个数量级上的⼤型数据库,但速度更快,MySQL就开发出来。
⾃1996年以来,我们⼀直都在使⽤MySQL,其环境有超过 40 个数据库,包含 10,000个表,其中500多个表超过7百万⾏,这⼤约有100 个吉字节(GB)的关键应⽤数据。
php中文参考手册
php中文参考手册以下是一个简化的PHP中文参考手册,以帮助您了解PHP的基本概念和语法:1. 简介PHP是一种流行的开源脚本语言,主要用于Web开发。
它被广泛用于构建动态网站和应用程序,并且与MySQL、SQLite等数据库兼容。
2. 语法基础常量与变量常量是一个在程序中定义的值,它不能被改变。
变量是用于存储数据的标识符,可以存储不同类型的数据,如字符串、数字、数组等。
运算符PHP支持各种运算符,包括算术运算符(如+、-、、/)、比较运算符(如==、!=、>、<、>=、<=)、逻辑运算符(如&&、、!)等。
流程控制PHP提供了if语句、switch语句和循环语句(如for、while)等流程控制结构,用于控制程序的执行流程。
3. 函数与类PHP具有丰富的内置函数和自定义函数库,可以用于执行各种任务,如文件操作、数据库交互等。
此外,PHP还支持面向对象编程(OOP),可以通过类来封装属性和方法。
4. 数据库交互PHP与数据库兼容,可以轻松地与MySQL、SQLite等数据库进行交互。
通过使用适当的函数和查询语句,可以执行数据库操作,如插入、更新、删除和查询数据。
5. Web开发PHP在Web开发中具有广泛的应用。
您可以使用PHP来处理表单数据、生成动态网页内容、与Web服务器进行通信等。
通过与HTML和CSS的结合,可以构建功能强大的Web应用程序。
以上是一个简化的PHP中文参考手册,旨在帮助您了解PHP的基本概念和语法。
要深入了解PHP的更多功能和用法,请参考官方文档或相关书籍。
Php函数完整参考手册
Php函数完整参考⼿册序号分类描述1Array 函数 2Calendar 函数⽇历扩展包含了简化不同⽇历格式间的转换的函数。
3Date/Time 函数Date/Time 函数⽤于从 PHP 脚本运⾏的服务器上获取⽇期和时间并进⾏格式化。
4Directory 函数Directory 函数⽤于获得关于⽬录及其内容的信息。
5Error/Logging函数Error/Logging 函数⽤于对错误进⾏处理和记录。
6Filesystem 函数Filesystem 函数⽤于访问和操作⽂件系统。
7Filter 函数PHP 过滤器⽤于对来⾃⾮安全来源的数据(⽐如⽤户输⼊)进⾏验证和过滤。
8FTP 函数FTP 函数通过⽂件传输协议 (FTP) 提供对⽂件服务器的客户端访问。
9HTTP 函数HTTP 函数⽤于对由 Web 服务器发送到浏览器的信息进⾏操作。
10Libxml 函数Libxml 函数和常量与 SimpleXML、XSLT 以及 DOM 函数⼀起使⽤。
11Mail 函数mail() 函数⽤于从脚本中直接发送电⼦邮件。
12Math 函数Math 函数能处理 integer 和 float 范围内的值。
13杂项函数我们把不属于其他类别的函数归纳到杂项函数类别。
14MySQLi 函数MySQLi 函数⽤于访问 MySQL 数据库服务器。
15SimpleXML 函数SimpleXML 扩展提供了⼀种获取 XML 元素的名称和⽂本的简单⽅式。
16String 函数 17XML Parser 函数XML Parser 函数允许您创建 XML 解析器,并为 XML 事件定义句柄。
18Zip File 函数Zip File 函数允许您读取压缩⽂件。
php、mysql主要参考文献
php、mysql主要参考文献以下是一些关于PHP和MySQL的主要参考文献:1. "PHP and MySQL Web Development" by Luke Welling and Laura Thomson - 这本书是学习PHP和MySQL的经典指南,涵盖了从基础到高级的内容。
2. "Learning PHP, MySQL & JavaScript" by Robin Nixon - 这本书提供了一个全面的入门指南,涵盖了PHP、MySQL和JavaScript的基础知识。
3. "PHP Cookbook" by David Sklar and Adam Trachtenberg - 这本书是一本实用的参考书,提供了大量的PHP编程示例和解决方案。
4. "MySQL Explained: Your Step-by-Step Guide" by Andrew Comeau - 这本书解释了MySQL数据库的基本概念和操作,适合初学者。
5. "High Performance MySQL: Optimization, Backups, and Replication" by Baron Schwartz, Peter Zaitsev, and Vadim Tkachenko - 这本书讲解了如何优化、备份和复制MySQL数据库,适合有经验的开发人员。
6. "PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide" by Larry Ullman - 这本书提供了一个简洁的指南,教你如何使用PHP 和MySQL构建动态网站。
这些参考文献将为你提供关于PHP和MySQL的广泛知识,并帮助你更好地理解和应用它们。
MySQL::MySQL5.1参考手册::27.扩展MySQL
MySQL::MySQL5.1参考手册::27.扩展MySQL27.2. 为MySQL添加新函数27.2.1. 自定义函数接口的特性27.2.2. CREATE FUNCTION/DROP FUNCTION 语法27.2.3. 添加新的自定义函数27.2.4. 添加新的固有函数有两个途径来为MySQL添加新函数:•你可以通过自行医函数接口 (UDF)来添加函数。
自定义函数被编译为目标文件,然后用CREATE FUNCTION 和DROP FUNCTION 声明动态地添入到服务器中及从服务器中移出。
参阅27.2.2节,“CREATE FUNCTION/DROP FUNCTION 语法”。
•你可以将函数添加为MySQL固有(内建)函数。
固有函数被编译进mysqld服务器中,成为永久可用的。
每种途径都有其优点和缺点:•如果你编写自定义函数,你除了安装服务器本身之外还要安装目标文件。
如果将你的函数编译进服务器中,你就不需要这么做了。
•你可以给二进制版本的MySQL分发版添加UDF。
固有函数需要你去修正源码分发版。
.•如果你升级你的MySQL分发版,你可以继续使用先前安装了的UDF,除非你升级到一个UDF接口改变了的新版本。
对固有函数而言,每次升级你都必须重复一次修正。
无论你使用哪种方法去添加新函数,它们都可以被SQL声明调用,就像 ABS() 或 SOUNDEX()这样的固有函数一样。
另一个添加函数的方法时创建存储函数。
这些函数时用SQL声明编写的,而不是编译目标代码。
编写存储函数的语法在第20章:存储程序和函数中描述。
下面的小节描述UDF接口的特性,给出编写UDF的指令,并讨论MySQL为防止UDF被误用而采取的安全预防措施。
给出源代码的例子来说明如何编写UDF,看一看MySQL源码分发版中提供的sql/udf_ 文件。
27.2.1. 自定义函数接口的特性MySQL自定义函数接口有如下特性和功能:•函数能分÷返回字符串,整数或实数。
mysql操作手册
上机11、安装Mysql;注意:设置超级用户密码的时候,统一设置为12342、进入Mysql;开始->程序->MySQL->MySQL Server 5.0->MySQL Command Line Client3、建立数据库BANKxxx;create database BANKxxx; --xxx为你的学号后三位show databases; --验证是否建立成功//命令必须在后面加分号否则出错,如果show databases;打成了show database;的话,也会错误,错误如下:正常情况下是如下:4、使用数据库BANK;use BANKxxx; --使用数据库BANKshow tables; --数据库中没有表因为此时BANK234为空表。
5、建立表BRANCHxxx, CUSTOMERxxx, LOANxxx, BORROWERxxx,ACCOUNTxxx, DEPOSITORxxx;Creating DataBase☞Creating the Banking database:Database Schema:branch (branch_name, branch_city, assets)customer (customer_name, customer_street, customer_city)depositor (customer_name, account_number)account (account_number, branch_name, balance)borrower(customer_name, loan_number)loan (loan_number, branch_name, amount)Creating database Banking steps:1) CREATE DATABASE Banking… (syntax lie onDBMS)2) Creating referenced tables(被参照关系)3) Creating referencing tables4) Creating other object of databaseCreating Tables//Creating table customer in SQLCREATE TABLE customer (customer_name char(20),customer_street char(30) NOT NULL,customer_city char(30)) ;CREATE TABLE ACCOUNTxxx (account_number char(10),branch_name char(30) NOT NULL,balance numeric(12.2),PRIMARY KEY (account_number),FOREIGN KEY (branch_name)REFERENCES branch(branch_name),CONSTRAINT chk_balance CHECK (balance >= 0 ) ) ;//注意此处必须保证表branch存在,如果不存在的话,先创建branch表吧,否则会报错如图1,原因如下:Integrity Constraints in Tables☞Create table with constraintsCREATE TABLE account (account_number char(10),branch_name char(30) NOT NULL,balance numeric(12.2),PRIMARY KEY (account_number),FOREIGN KEY (branch_name)REFERENCES branch(branch_name),CONSTRAINT chk_balance CHECK (balance >= 0 ) ) ;The referenced table must be an existing relation!Integrity constraints can be added to an existing relation,if the relation does not satisfies the constraint, reject!Constraint name make it easy to drop.图1//注意:在换行输入时,最后那个括号前到语句后面是不能跟逗号的发生错误的截图如下:正确的截图如下:--建立customersxxx表,xxx同前show tables; --现在数据库中有了表desc customers; --查看表的属性以下为创建数据库bankToT的代码:1创建数据库:create database bankToT;删除数据库命令格式为:drop database databasename ;删除表命令:Drop table tablename;2 在刚才创建的数据库中创建表命令格式:use databasename; //这个命令允许无结尾分号//创建表branchCREATE TABLE branch(branch_name char(20),branch_city char(30) NOT NULL,assets char(30) NOT NULL) ;//创建表customerCREATE TABLE customer (customer_name char(20),customer_street char(30) NOT NULL,customer_city char(30)) ;截图如下://创建表account命令:CREATE TABLE account (account_number char(20),branch_name char(20) NOT NULL,balance numeric(12.2),PRIMARY KEY (account_number),FOREIGN KEY (branch_name)REFERENCES branch(branch_name),CONSTRAINT chk_balance CHECK (balance >= 0 ) ) ;然后可能会报错:如下:原因:因为在创建branch表的时候没有将branch_name设置为主键也就是primary key,你可以翻看之前创建branch表的代码,里面没有primary key(branch_name)这句。
Mysql实验手册
《Mysql实验手册》目录第一章Mysql在Windows上安装 (3)第一节安装环境 (3)第二节Mysql版本和程序包 (3)第三节具体安装步骤 (4)第四节Mysql服务启动 (19)第二章Mysql常用配置 (20)第一节Mysql命令行客户端配置数据库 (20)1.登陆Mysql数据库 (20)第二节Mysql客户端工具 (21)1.MySQL-Front的安装 (22)2.创建用户 (28)3.数据表的基本操作 (30)第三章Mysql实验 (36)第一节实验一创建数据库 (37)第二节实验二创建用户 (38)第三节实验三创建表 (39)第四节实验四增加主键 (40)第五节实验五插入记录 (41)第六节实验六更新记录 (43)第七节实验七删除记录 (44)第八节实验八单表查询 (45)第九节实验九分组查询 (46)第十节实验十联合查询 (47)第十一节实验十一查询平均分 (48)第十二节实验十二联合查询排序 (49)第十三节实验十三联合查询最大值、最小值 (50)第十四节实验十四删除表 (51)第十五节实验十五增加字段 (52)第十六节实验十六修改字段名称 (53)第十七节实验十七修改字段属性 (54)第十八节实验十八删除字段 (55)第十九节实验十九导入导出数据 (55)1.导出数据mysqldump (56)2.mysqlimport命令 (56)3.导入数据 (57)4.将文本数据导入数据库 (57)第一章Mysql在Windows上安装第一节安装环境Windows XP操作系统上安装。
第二节Mysql版本和程序包Mysql版本:Mysql 5.5.27安装程序包:MySql安装包.zip(下载地址:/s/1qXAax68 访问密码1vsy)第三节具体安装步骤将安装程序包拷贝到电脑上,然后解压。
选中mysql-5.5.27-winx64(或mysql-5.5.27-winx32)进行安装。
01MySQL数据库安装明细手册-10页word资料
MySQL for Windows数据库安装操作手册对于大多数朋友而言,MySQL的安装非常简单,基本上一路next下来,就可以完成安装。
但是知其然更要知其所以然,在此结合MySQL联机文档来详细介绍MySQL的安装,让我们更清楚MySQL的安装。
安装总共20步,1 - 5步完成MySQL基本安装;6 -18完成MySQL优化安装;19-20完成系统完善。
环境准备:1、32位Windows操作系统,例如9x、Me、NT、2000、XP或Windows Server 20032、TCP/IP协议支持(一般系统都默认支持)3、MySQL5.0安装包(可以到官网上下载)开始安装:1、双击安装程序,出现安装界面:2、点击“next”,出现如下界面简述:Typical(典型安装): 安装MySQL服务器、mysql命令行客户端和命令行实用程序。
命令行客户端和实用程序包括mysqldump、myisamchk 和其它几个工具来帮助你管理MySQL服务器。
推荐一般用户安装。
Complete(完全安装): 安装将安装软件包内包含的所有组件。
完全安装软件包包括的组件包括嵌入式服务器库、基准套件、支持脚本和文档。
Custom(定制安装): 安装允许你完全控制你想要安装的软件包和安装路径。
一般而言,推荐选择‘典型安装’。
MySQL的基本功能都包含其中,也满足我们的基本功能需要。
3、点击“next”,出现如下界面简述:当前配置:安装类型:典型安装路径:C:\Program Files\MySQL Server 5.0\此处描述了当前安装的类型以及即将被安装的位置。
4、点击“Install”,经过一段安装进度时间之后,出现如下界面, 选择第三项“skip sign-up”,点击“next”简述:免费创建一个MySQL帐户登陆MySQL跳过免费创建一个MySQL帐户,连接网络登陆http://mysql/register.php 完成一系列注册,成为MySQL的一个注册用户。
MySQL手册
Skip navigation linksThe world's most popular open source databaseLogin | Register∙Developer Zone∙Downloads∙Documentation∙MySQL Server∙MySQL Enterprise∙MySQL Workbench∙MySQL Cluster∙Topic Guides∙Expert Guides∙Other Docs∙Archives∙About∙Documentation Libraryo Table of ContentsSearch manual:第1章:一般信息目录1.1. 关于本手册1.2. 本手册采用的惯例1.3. MySQL AB概述1.4. MySQL数据库管理系统概述1.4.1. MySQL的历史1.4.2. MySQL的的主要特性1.4.3. MySQL稳定性1.4.4. MySQL表最大能达到多少1.4.5. 2000年兼容性1.5. MaxDB数据库管理系统概述1.5.1. 什么是MaxDB?1.5.2. MaxDB的历史1.5.3. MaxDB的特性1.5.4. 许可和支持1.5.5. MaxDB和MySQL之间的特性差异1.5.6. MaxDB和MySQL之间的协同性1.5.7. 与MaxDB有关的链接1.6. MySQL发展大事记1.6.1. MySQL 5.1的新特性1.7. MySQL信息源1.7.1. MySQL邮件列表1.7.2. IRC(在线聊天系统)上的MySQL社区支持1.7.3. MySQL论坛上的MySQL社区支持1.8. MySQL标准的兼容性1.8.1. MySQL遵从的标准是什么1.8.2. 选择SQL模式1.8.3. 在ANSI模式下运行MySQL1.8.4. MySQL对标准SQL的扩展1.8.5. MySQL与标准SQL的差别1.8.6. MySQL处理约束的方式MySQL®软件提供了十分快速的多线程、多用户、牢靠的SQL(结构化查询语言)数据库服务器。
PHP完全自学手册
2021/2/4
1
4
1.1.2 PHP语言相关术语
• (4)什么是对象? • 对象就是类存在于内存中的实例,通过对类进行实例化,
就能得到对应的对象。 • (5)什么是函数? • 函数是一段相对独立的代码,不同的语言有不同的定义方
式。在PHP中,函数就是有效的PHP代码的集合。在设计复 杂程序时,可以把程序分为几个函数,不同的函数完成不 同的功能。其优点在于各部分充分独立,不仅可以使程序 易读、易维护,还可以对代码进行复用。 • (6)什么是Session? • Session用中文来解释就是会话期。一个会话期开始于用户 输入一个站点的网址时,结束于离开这个站点时。PHP使用 Session函数来创建和管理会话期内“$_SESSION”中的变 量。
• 本节介绍的仅限于常用的术语,在PHP语言学习的过程中,应该多 注意对PHP专业术语和其他通用专业术语的学习和集累。
2021/2/4
1
8
1.2 PHP的运行及开发环境
• 在上一节中,提到了几个术语,即:SDE、LAMP、 WAMP和Eclipse。SDE,即软件开发环境,它由软 件运行环境和软件开发工具两部分组成。LAMP和 WAMP都是软件的运行环境;Eclipse是本书使用到 的开发工具。
1
12
1.2.4 准备工作
• 从本节开始,学习建立一台实现上述功能的主机。 • (1)一台已经安装了Windows XP/2000/2003系
统的电脑。(关于Windows 的安装过程,请参照 其他书籍)。本书使用是Windows XP系统。 • (2)登录Apache官方网站 /,下载最新版本的安装 程序,本书中使用的是Apache 2.2.6 Released, 详细下载地址: /httpd/bin aries/win32/apache_ 2.2.6-win32-x86openssl-0.9.8e.msi。
win7下apache_mysql_php_svn_usvn搭建手册
win7下apache+mysql+php+usvn+svn搭建手册目的:由于老的USVN服务机器宕了,故需重新搭建usvn的服务器环境,现整体文档一份,供以后大家参考。
环境搭建所需软件包信息如下:apache 2.2.21安装包:httpd-2.2.21-win32-x86-openssl-0.9.8r.msiphp 5.2.17安装包:php-5.2.17-Win32-VC6-x86.msimysql 5.1.59安装包:mysql-essential-5.1.59-win32usvn 1.0.1: usvn-1.0.1.zipsvn server安装包: TortoiseSVN-1.6.16.21511-win32-svn-1.6.17.msi说明:USVN是一个基于PHP环境上针对SVN进行可视化管理的web工具,功能数据存储在mysql数据库中,故要搭建出完整的USVN环境,需要安装以上软件。
(安装文件可到组内共享文件服务器上去获取)安装配置步骤清单:Windows 7下安装Apache服务Windows 7下安装Mysql服务在Windows 7下安装及配置PHP在Windows 7下如何进行PHP配置环境。
配置Apache以支持PHP配置Mysql服务器安装SVN server端及创建一个SVN系统服务安装USVN并配置httpd.conf文件在Apache中配置SVN 服务搭建USVN web服务安装配置步骤如下:USVN环境搭建第一步:Windows 7下安装Apache服务Apache版本:httpd-2.2.15-win32-x86-openssl-0.9.8m-r2,openssl表示带有openssl模块,利用openssl可给Apache配置SSL安全链接。
Apache配置信息在这里主要配置Network Domain、Server Name、Email地址以及Apache 服务的占用端口,默认为80端口,你可以根据需要配置在其他端口,Apache的安装目录你可以使用默认目录或根据需要自行选择安装目录。
mysql手册
MySQL TutorialMySQL TutorialAbstractThis is the MySQL Tutorial from the MySQL5.5Reference Manual.Document generated on:2009-12-19(revision:18355)Copyright©1997-2008MySQL AB,2009Sun Microsystems,Inc.All rights ernment Rights-Commercial ernment users are subject to the Sun Microsystems,Inc.standard license agreement and applicable provisions of the FAR and its e is subject to li-cense terms.Sun,Sun Microsystems,the Sun logo,Java,Solaris,StarOffice,MySQL Enterprise Monitor2.0,MySQL logo™and MySQL™are trade-marks or registered trademarks of Sun Microsystems,Inc.in the U.S.and other countries.UNIX is a registered trademark in the U.S.and other countries, exclusively licensed through X/Open Company,Ltd.Copyright©1997-2008MySQL AB,2009Sun Microsystems,Inc.Tous droits réservés.L'utilisation est soumise aux termes du contrat de licence.Sun, Sun Microsystems,le logo Sun,Java,Solaris,StarOffice,MySQL Enterprise Monitor2.0,MySQL logo™et MySQL™sont des marques de fabrique ou des marques déposées de Sun Microsystems,Inc.aux Etats-Unis et dans d'autres pays.UNIX est une marque déposée aux Etats-Unis et dans d'autres pays et licenciée exlusivement par X/Open Company,Ltd.This documentation is NOT distributed under a GPL e of this documentation is subject to the following terms:You may create a printed copy of this documentation solely for your own personal use.Conversion to other formats is allowed as long as the actual content is not altered or edited in any way.You shall not publish or distribute this documentation in any form or on any media,except if you distribute the documentation in a manner sim-ilar to how Sun disseminates it(that is,electronically for download on a Web site with the software)or on a CD-ROM or similar medium,provided however that the documentation is disseminated together with the software on the same medium.Any other use,such as any dissemination of printed copies or use of this documentation,in whole or in part,in another publication,requires the prior written consent from an authorized representative of Sun Microsystems,Inc.Sun Microsystems,Inc.and MySQL AB reserve any and all rights to this documentation not expressly granted above.For more information on the terms of this license,for details on how the MySQL documentation is built and produced,or if you are interested in doing a translation,please contact the Documentation Team.For additional licensing information,including licenses for libraries used by MySQL,see Preface,Notes,Licenses.If you want help with using MySQL,please visit either the MySQL Forums or MySQL Mailing Lists where you can discuss your issues with other MySQL users.For additional documentation on MySQL products,including translations of the documentation into other languages,and downloadable versions in vari-ety of formats,including HTML,CHM,and PDF formats,see MySQL Documentation Library.TutorialThis chapter provides a tutorial introduction to MySQL by showing how to use the mysql client program to create and use a simpledatabase.mysql(sometimes referred to as the“terminal monitor”or just“monitor”)is an interactive program that allows you to con-nect to a MySQL server,run queries,and view the results.mysql may also be used in batch mode:you place your queries in a file be-forehand,then tell mysql to execute the contents of the file.Both ways of using mysql are covered here.To see a list of options provided by mysql,invoke it with the--help option:This chapter assumes that mysql is installed on your machine and that a MySQL server is available to which you can connect.If this is not true,contact your MySQL administrator.(If you are the administrator,you need to consult the relevant portions of this manual,such as MySQL Server Administration.)This chapter describes the entire process of setting up and using a database.If you are interested only in accessing an existing database, you may want to skip over the sections that describe how to create the database and the tables it contains.Because this chapter is tutorial in nature,many details are necessarily omitted.Consult the relevant sections of the manual for more in-formation on the topics covered here.Chapter1.Connecting to and Disconnecting from the Server To connect to the server,you will usually need to provide a MySQL user name when you invoke mysql and,most likely,a password.If the server runs on a machine other than the one where you log in,you will also need to specify a host name.Contact your administrat-or to find out what connection parameters you should use to connect(that is,what host,user name,and password to use).Once youknow the proper parameters,you should be able to connect like this:host and user represent the host name where your MySQL server is running and the user name of your MySQL account.Substituteappropriate values for your setup.The********represents your password;enter it when mysql displays the Enter password: prompt.If that works,you should see some introductory information followed by a mysql>prompt:The mysql>prompt tells you that mysql is ready for you to enter commands.If you are logging in on the same machine that MySQL is running on,you can omit the host,and simply use the following:If,when you attempt to log in,you get an error message such as ERROR2002(HY000):C AN'T CONNECT TO LOCAL M Y SQLSERVER THROUGH SOCKET'/TMP/MYSQL.SOCK'(2),it means that the MySQL server daemon(Unix)or service(Windows)is notrunning.Consult the administrator or see the section of Installing and Upgrading MySQL that is appropriate to your operating system.For help with other problems often encountered when trying to log in,see Common Errors When Using MySQL Programs.Some MySQL installations allow users to connect as the anonymous(unnamed)user to the server running on the local host.If this is the case on your machine,you should be able to connect to that server by invoking mysql without any options:After you have connected successfully,you can disconnect any time by typing QUIT(or\q)at the mysql>prompt:On Unix,you can also disconnect by pressing Control-D.Most examples in the following sections assume that you are connected to the server.They indicate this by the mysql>prompt.Chapter2.Entering QueriesMake sure that you are connected to the server,as discussed in the previous section.Doing so does not in itself select any database towork with,but that is okay.At this point,it is more important to find out a little about how to issue queries than to jump right in creating tables,loading data into them,and retrieving data from them.This section describes the basic principles of entering commands,usingseveral queries you can try out to familiarize yourself with how mysql works.Here is a simple command that asks the server to tell you its version number and the current date.Type it in as shown here following the mysql>prompt and press Enter:This query illustrates several things about mysql:•A command normally consists of an SQL statement followed by a semicolon.(There are some exceptions where a semicolon may be omitted.QUIT,mentioned earlier,is one of them.We'll get to others later.)•When you issue a command,mysql sends it to the server for execution and displays the results,then prints another mysql> prompt to indicate that it is ready for another command.•mysql displays query output in tabular form(rows and columns).The first row contains labels for the columns.The rows following are the query results.Normally,column labels are the names of the columns you fetch from database tables.If you're retrieving thevalue of an expression rather than a table column(as in the example just shown),mysql labels the column using the expression it-self.•mysql shows how many rows were returned and how long the query took to execute,which gives you a rough idea of server per-formance.These values are imprecise because they represent wall clock time(not CPU or machine time),and because they are af-fected by factors such as server load and network latency.(For brevity,the“rows in set”line is sometimes not shown in the remain-ing examples in this chapter.)Keywords may be entered in any lettercase.The following queries are equivalent:Here is another query.It demonstrates that you can use mysql as a simple calculator:The queries shown thus far have been relatively short,single-line statements.You can even enter multiple statements on a single line.Just end each one with a semicolon:A command need not be given all on a single line,so lengthy commands that require several lines are not a problem.mysql determines where your statement ends by looking for the terminating semicolon,not by looking for the end of the input line.(In other words, mysql accepts free-format input:it collects input lines but does not execute them until it sees the semicolon.)Here is a simple multiple-line statement:In this example,notice how the prompt changes from mysql>to->after you enter the first line of a multiple-line query.This is how mysql indicates that it has not yet seen a complete statement and is waiting for the rest.The prompt is your friend,because it provides valuable feedback.If you use that feedback,you can always be aware of what mysql is waiting for.If you decide you do not want to execute a command that you are in the process of entering,cancel it by typing\c:Here,too,notice the prompt.It switches back to mysql>after you type\c,providing feedback to indicate that mysql is ready for a new command.The following table shows each of the prompts you may see and summarizes what they mean about the state that mysql is in.Prompt Meaningmysql>Ready for new command.->Waiting for next line of multiple-line command.'>Waiting for next line,waiting for completion of a string that began with a single quote(“'”).">Waiting for next line,waiting for completion of a string that began with a double quote(“"”).`>Waiting for next line,waiting for completion of an identifier that began with a backtick(“`”)./*>Waiting for next line,waiting for completion of a comment that began with/*.Multiple-line statements commonly occur by accident when you intend to issue a command on a single line,but forget the terminating semicolon.In this case,mysql waits for more input:If this happens to you(you think you've entered a statement but the only response is a->prompt),most likely mysql is waiting for the semicolon.If you don't notice what the prompt is telling you,you might sit there for a while before realizing what you need to do.Enter a semicolon to complete the statement,and mysql executes it:The'>and">prompts occur during string collection(another way of saying that MySQL is waiting for completion of a string).In MySQL,you can write strings surrounded by either“'”or“"”characters(for example,'hello'or"goodbye"),and mysql lets you enter strings that span multiple lines.When you see a'>or">prompt,it means that you have entered a line containing a string that begins with a“'”or“"”quote character,but have not yet entered the matching quote that terminates the string.This often indicates that you have inadvertently left out a quote character.For example:If you enter this SELECT statement,then press Enter and wait for the result,nothing happens.Instead of wondering why this query takes so long,notice the clue provided by the'>prompt.It tells you that mysql expects to see the rest of an unterminated string.(Do you see the error in the statement?The string'Smith is missing the second single quote mark.)At this point,what do you do?The simplest thing is to cancel the command.However,you cannot just type\c in this case,because mysql interprets it as part of the string that it is collecting.Instead,enter the closing quote character(so mysql knows you've finished the string),then type\c:The prompt changes back to mysql>,indicating that mysql is ready for a new command.The`>prompt is similar to the'>and">prompts,but indicates that you have begun but not completed a backtick-quoted identifier. It is important to know what the'>,">,and`>prompts signify,because if you mistakenly enter an unterminated string,any further lines you type appear to be ignored by mysql—including a line containing QUIT.This can be quite confusing,especially if you do not know that you need to supply the terminating quote before you can cancel the current command.Chapter3.Creating and Using a DatabaseOnce you know how to enter commands,you are ready to access a database.Suppose that you have several pets in your home(your menagerie)and you would like to keep track of various types of informationabout them.You can do so by creating tables to hold your data and loading them with the desired information.Then you can answer dif-ferent sorts of questions about your animals by retrieving data from the tables.This section shows you how to perform the following op-erations:•Create a database•Create a table•Load data into the table•Retrieve data from the table in various ways•Use multiple tablesThe menagerie database is simple(deliberately),but it is not difficult to think of real-world situations in which a similar type of data-base might be used.For example,a database like this could be used by a farmer to keep track of livestock,or by a veterinarian to keeptrack of patient records.A menagerie distribution containing some of the queries and sample data used in the following sections can be obtained from the MySQL Web site.It is available in both compressed tar file and Zip formats at /doc/.Use the SHOW statement to find out what databases currently exist on the server:The mysql database describes user access privileges.The test database often is available as a workspace for users to try things out.The list of databases displayed by the statement may be different on your machine;SHOW DATABASES does not show databases thatyou have no privileges for if you do not have the SHOW DATABASES privilege.See SHOW DATABASES Syntax.If the test database exists,try to access it:USE,like QUIT,does not require a semicolon.(You can terminate such statements with a semicolon if you like;it does no harm.)TheUSE statement is special in another way,too:it must be given on a single line.You can use the test database(if you have access to it)for the examples that follow,but anything you create in that database can beremoved by anyone else with access to it.For this reason,you should probably ask your MySQL administrator for permission to use adatabase of your own.Suppose that you want to call yours menagerie.The administrator needs to execute a command like this:where your_mysql_name is the MySQL user name assigned to you and your_client_host is the host from which you connect to the server.3.1.Creating and Selecting a DatabaseIf the administrator creates your database for you when setting up your permissions,you can begin using it.Otherwise,you need to cre-ate it yourself:Creating and Using a DatabaseUnder Unix,database names are case sensitive(unlike SQL keywords),so you must always refer to your database as menagerie,not as Menagerie,MENAGERIE,or some other variant.This is also true for table names.(Under Windows,this restriction does not ap-ply,although you must refer to databases and tables using the same lettercase throughout a given query.However,for a variety of reas-ons,the recommended best practice is always to use the same lettercase that was used when the database was created.)NoteIf you get an error such as ERROR1044(42000):A CCESS DENIED FOR USER'MONTY'@'LOCALHOST'TO DATA-BASE'MENAGERIE'when attempting to create a database,this means that your user account does not have the necessaryprivileges to do so.Discuss this with the administrator or see The MySQL Access Privilege System.Creating a database does not select it for use;you must do that explicitly.To make menagerie the current database,use this com-mand: ArrayYour database needs to be created only once,but you must select it for use each time you begin a mysql session.You can do this by is-suing a USE statement as shown in the example.Alternatively,you can select the database on the command line when you invokeexample:mysql.Just specify its name after any connection parameters that you might need to provide.For Array Importantmenagerie in the command just shown is not your password.If you want to supply your password on the command lineafter the-p option,you must do so with no intervening space(for example,as-pmypassword,not as-p mypass-word).However,putting your password on the command line is not recommended,because doing so exposes it to snoop-ing by other users logged in on your machine.NoteYou can see at any time which database is currently selected using SELECT DATABASE().3.2.Creating a Tableyou:Creating the database is the easy part,but at this point it is empty,as SHOW TABLES tells ArrayThe harder part is deciding what the structure of your database should be:what tables you need and what columns should be in each of them.You want a table that contains a record for each of your pets.This can be called the pet table,and it should contain,as a bare minim-um,each animal's name.Because the name by itself is not very interesting,the table should contain other information.For example,ifmore than one person in your family keeps pets,you might want to list each animal's owner.You might also want to record some basic descriptive information such as species and sex.How about age?That might be of interest,but it is not a good thing to store in a database.Age changes as time passes,which meansyou'd have to update your records often.Instead,it is better to store a fixed value such as date of birth.Then,whenever you need age,you can calculate it as the difference between the current date and the birth date.MySQL provides functions for doing date arithmetic,so this is not difficult.Storing birth date rather than age has other advantages,too:•You can use the database for tasks such as generating reminders for upcoming pet birthdays.(If you think this type of query is somewhat silly,note that it is the same question you might ask in the context of a business database to identify clients to whom youneed to send out birthday greetings in the current week or month,for that computer-assisted personal touch.)•You can calculate age in relation to dates other than the current date.For example,if you store death date in the database,you can easily calculate how old a pet was when it died.You can probably think of other types of information that would be useful in the pet table,but the ones identified so far are sufficient: name,owner,species,sex,birth,and death.Use a CREATE TABLE statement to specify the layout of your table:VARCHAR is a good choice for the name,owner,and species columns because the column values vary in length.The lengths inthose column definitions need not all be the same,and need not be20.You can normally pick any length from1to65535,whateverseems most reasonable to you.If you make a poor choice and it turns out later that you need a longer field,MySQL provides an ALTER TABLE statement.Several types of values can be chosen to represent sex in animal records,such as'm'and'f',or perhaps'male'and'female'.It is simplest to use the single characters'm'and'f'.The use of the DATE data type for the birth and death columns is a fairly obvious choice.Once you have created a table,SHOW TABLES should produce some output:To verify that your table was created the way you expected,use a DESCRIBE statement:You can use DESCRIBE any time,for example,if you forget the names of the columns in your table or what types they have.For more information about MySQL data types,see Data Types.3.3.Loading Data into a TableAfter creating your table,you need to populate it.The LOAD DATA and INSERT statements are useful for this.Suppose that your pet records can be described as shown here.(Observe that MySQL expects dates in'YYYY-MM-DD'format;thismay be different from what you are used to.)name owner species sex birth deathFluffy Harold cat f1993-02-04Claws Gwen cat m1994-03-17Buffy Harold dog f1989-05-13Fang Benny dog m1990-08-27Bowser Diane dog m1979-08-311995-07-29Chirpy Gwen bird f1998-09-11Whistler Gwen bird1997-12-09Slim Benny snake m1996-04-29Because you are beginning with an empty table,an easy way to populate it is to create a text file containing a row for each of your an-imals,then load the contents of the file into the table with a single statement.You could create a text file pet.txt containing one record per line,with values separated by tabs,and given in the order in which the columns were listed in the CREATE TABLE statement.For missing values(such as unknown sexes or death dates for animals that arestill living),you can use NULL values.To represent these in your text file,use\N(backslash,capital-N).For example,the record forWhistler the bird would look like this(where the whitespace between values is a single tab character):To load the text file pet.txt into the pet table,use this statement:If you created the file on Windows with an editor that uses\r\n as a line terminator,you should use this statement instead:(On an Apple machine running OS X,you would likely want to use LINES TERMINATED BY'\r'.)You can specify the column value separator and end of line marker explicitly in the LOAD DATA statement if you wish,but the defaults are tab and linefeed.These are sufficient for the statement to read the file pet.txt properly.If the statement fails,it is likely that your MySQL installation does not have local file capability enabled by default.See Security Issues with LOAD DATA LOCAL,for information on how to change this.When you want to add new records one at a time,the INSERT statement is useful.In its simplest form,you supply values for eachcolumn,in the order in which the columns were listed in the CREATE TABLE statement.Suppose that Diane gets a new hamster named “Puffball.”You could add a new record using an INSERT statement like this:String and date values are specified as quoted strings here.Also,with INSERT,you can insert NULL directly to represent a missingvalue.You do not use\N like you do with LOAD DATA.From this example,you should be able to see that there would be a lot more typing involved to load your records initially using several INSERT statements rather than a single LOAD DATA statement.3.4.Retrieving Information from a TableThe SELECT statement is used to pull information from a table.The general form of the statement is:what_to_select indicates what you want to see.This can be a list of columns,or*to indicate“all columns.”which_table in-dicates the table from which you want to retrieve data.The WHERE clause is optional.If it is present,conditions_to_satisfyspecifies one or more conditions that rows must satisfy to qualify for retrieval.3.4.1.Selecting All DataThe simplest form of SELECT retrieves everything from a table:This form of SELECT is useful if you want to review your entire table,for example,after you've just loaded it with your initial data set.For example,you may happen to think that the birth date for Bowser doesn't seem quite right.Consulting your original pedigree papers, you find that the correct birth year should be1989,not1979.There are at least two ways to fix this:•Edit the file pet.txt to correct the error,then empty the table and reload it using DELETE and LOAD DATA:However,if you do this,you must also re-enter the record for Puffball.•Fix only the erroneous record with an UPDATE statement:The UPDATE changes only the record in question and does not require you to reload the table.3.4.2.Selecting Particular RowsAs shown in the preceding section,it is easy to retrieve an entire table.Just omit the WHERE clause from the SELECT statement.Buttypically you don't want to see the entire table,particularly when it becomes large.Instead,you're usually more interested in answeringa particular question,in which case you specify some constraints on the information you want.Let's look at some selection queries interms of questions about your pets that they answer.You can select only particular rows from your table.For example,if you want to verify the change that you made to Bowser's birth date, select Bowser's record like this:The output confirms that the year is correctly recorded as1989,not1979.String comparisons normally are case-insensitive,so you can specify the name as'bowser','BOWSER',and so forth.The query res-ult is the same.You can specify conditions on any column,not just name.For example,if you want to know which animals were born during or after1998,test the birth column:You can combine conditions,for example,to locate female dogs:The preceding query uses the AND logical operator.There is also an OR operator:AND and OR may be intermixed,although AND has higher precedence than OR.If you use both operators,it is a good idea to use paren-theses to indicate explicitly how conditions should be grouped:3.4.3.Selecting Particular ColumnsIf you do not want to see entire rows from your table,just name the columns in which you are interested,separated by commas.For ex-ample,if you want to know when your animals were born,select the name and birth columns:To find out who owns pets,use this query:Notice that the query simply retrieves the owner column from each record,and some of them appear more than once.To minimize the output,retrieve each unique output record just once by adding the keyword DISTINCT:You can use a WHERE clause to combine row selection with column selection.For example,to get birth dates for dogs and cats only,use this query:3.4.4.Sorting RowsYou may have noticed in the preceding examples that the result rows are displayed in no particular order.It is often easier to examinequery output when the rows are sorted in some meaningful way.To sort a result,use an ORDER BY clause.Here are animal birthdays,sorted by date:On character type columns,sorting—like all other comparison operations—is normally performed in a case-insensitive fashion.This means that the order is undefined for columns that are identical except for their case.You can force a case-sensitive sort for a column by using BINARY like so:ORDER BY BINARY col_name.The default sort order is ascending,with smallest values first.To sort in reverse(descending)order,add the DESC keyword to the name of the column you are sorting by:You can sort on multiple columns,and you can sort different columns in different directions.For example,to sort by type of animal inascending order,then by birth date within animal type in descending order(youngest animals first),use the following query:The DESC keyword applies only to the column name immediately preceding it(birth);it does not affect the species column sortorder.3.4.5.Date CalculationsMySQL provides several functions that you can use to perform calculations on dates,for example,to calculate ages or extract parts of dates.To determine how many years old each of your pets is,compute the difference in the year part of the current date and the birth date, then subtract one if the current date occurs earlier in the calendar year than the birth date.The following query shows,for each pet,the birth date,the current date,and the age in years.Here,YEAR()pulls out the year part of a date and RIGHT()pulls off the rightmost five characters that represent the MM-DD(calendar year)part of the date.The part of the expression that compares the MM-DD values evaluates to1or0,which adjusts the year difference down a year if CURDATE()occurs earlier in the year than birth.The full expression is somewhat ungainly,so an alias(age)is used to make the output column label more meaningful.The query works,but the result could be scanned more easily if the rows were presented in some order.This can be done by adding an ORDER BY name clause to sort the output by name:To sort the output by age rather than name,just use a different ORDER BY clause:A similar query can be used to determine age at death for animals that have died.You determine which animals these are by checking whether the death value is NULL.Then,for those with non-NULL values,compute the difference between the death and birth val-ues:。
【MySQL】7、MySQL函数参考手册
【MySQL】7、MySQL函数参考⼿册7.1、MySQL函数参考⼿册函数描述返回前⼀次 MySQL 操作所影响的记录⾏数。
打开或关闭⾃动提交数据库修改。
更改指定数据库连接的⽤户。
返回数据库连接的默认字符集。
关闭先前打开的数据库连接。
提交当前事务。
返回上⼀次连接错误的错误代码。
返回上⼀次连接错误的错误描述。
打开⼀个到 MySQL 服务器的新的连接。
调整结果指针到结果集中的⼀个任意⾏。
执⾏调试操作。
转储调试信息到⽇志中。
返回最近调⽤函数的最后⼀个错误代码。
返回最近调⽤函数的错误列表。
返回最近调⽤函数的最后⼀个错误描述。
从结果集中取得所有⾏作为关联数组,或数字数组,或⼆者兼有。
(获取查询出来的记录)从结果集中取得⼀⾏作为关联数组,或数字数组,或⼆者兼有。
(获取查询出来的记录)从结果集中取得⼀⾏作为关联数组。
从结果集中取得某个单⼀字段的 meta-data,并作为对象返回。
从结果集中取得下⼀字段,并作为对象返回。
返回结果中代表字段的对象的数组。
返回结果集中当前⾏的每个列的长度。
从结果集中取得当前⾏,并作为对象返回。
从结果集中取得⼀⾏,并作为枚举数组返回。
返回最近查询的列数。
把结果集中的指针设置为指定字段的偏移量。
返回结果集中的指针的位置。
释放结果内存。
返回字符集对象。
返回 MySQL 客户端库版本。
返回有关客户端每个进程的统计。
将 MySQL 客户端库版本作为整数返回。
返回有关客户端连接的统计。
返回 MySQL 服务器主机名和连接类型。
返回 MySQL 协议版本。
返回 MySQL 服务器版本。
将 MySQL 服务器版本作为整数返回。
返回有关最近执⾏查询的信息。
初始化 MySQLi 并返回 mysqli_real_connect() 使⽤的资源。
返回最后⼀个查询中⾃动⽣成的 ID。
请求服务器杀死⼀个 MySQL 线程。
检查⼀个多查询是否有更多的结果。
执⾏⼀个或多个针对数据库的查询。
为 mysqli_multi_query() 准备下⼀个结果集。
mysql 官方用户手册中文版
例如:
9
查询
mysql> select user()` `> ` -> /*
/*> */ -> ' '> ' -> " "> " -> \c
10
创建和使用数据庫
4.3 创建和使用数据庫
4.3.1 Creating and Selecting a Database 4.3.2 Creating a Table
7
查询
mysql> SELECT VERSION(), CURRENT_DATE; mysql> select version(), current_date; mysql> SeLeCt vErSiOn(), current_DATE;
以下是另一个查询,你可以使用mysql做一个简单的计算:
mysql> SELECT SIN(PI()/4), (4+1)*5;
+------------------+
1 row in set (0.00 sec)
+---------------------+
| NOW()
|
Mysql函数手册(PDF版)
M ysql函数手册日期函数:一、MySQL获得当前日期时间函数1.1获得当前日期+时间(date+time)函数:now()mysql>select now();+---------------------+|now()|+---------------------+|2008-08-0822:20:46|+---------------------+除了now()函数能获得当前的日期时间外,MySQL中还有下面的函数:current_timestamp(),current_timestamp,localtime(),localtime,localtimestamp--(v4.0.6),localtimestamp()--(v4.0.6)这些日期时间函数,都等同于now()。
鉴于now()函数简短易记,建议总是使用now()来替代上面列出的函数。
1.2获得当前日期+时间(date+time)函数:sysdate()sysdate()日期时间函数跟now()类似,不同之处在于:now()在执行开始时值就得到了,sysdate()在函数执行时动态得到值。
看下面的例子就明白了:mysql>select now(),sleep(3),now();+---------------------+----------+---------------------+|now()|sleep(3)|now()|+---------------------+----------+---------------------+|2008-08-0822:28:21|0|2008-08-0822:28:21|+---------------------+----------+---------------------+mysql>select sysdate(),sleep(3),sysdate();+---------------------+----------+---------------------+|sysdate()|sleep(3)|sysdate()|+---------------------+----------+---------------------+|2008-08-0822:28:41|0|2008-08-0822:28:44|+---------------------+----------+---------------------+可以看到,虽然中途sleep3秒,但now()函数两次的时间值是相同的;sysdate()函数两次得到的时间值相差3秒。
OpenBSD+Nginx+MySQL+PHP环境搭建手册[O.N.M.P第一版]
OpenBSD+Nginx+MySQL+PHP环境搭建手册[O.N.M.P第一版] OpenBSD.Nginx.MySQL.PHP环境搭建手册[O.N.M.P第一版]所谓的O.N.M.P.是指OpenBSD、Nginx、MySQL、PHP(fastcgi),是利用OpenBSD及其软件包搭建的时下流行的MySQL+PHP应用环境,下面对主要的软件做下介绍:OpenBSD:可能是这个星球最安全的操作系统了,在十几年的时间里面只被发现了两个远程安全漏洞。
Nginx:来自俄罗斯的HTTP软件,据说性能达到老牌的Apache十倍!并且极其节约资源,是单台服务器跑PHP应用的首选。
官方文档声称能达到5W个并发连接,生产环境下单台双核2.33G服务器可以跑到3W个并发连接(仅运行Nginx+PHP-fastcgi)。
MySQL:老牌的开源数据库软件。
PHP:这个几乎无人不知,和MySQL一起构成了开源环境下最强的建站组合。
下面以OpenBSD 4.4为例进行讲解。
按照惯例,root环境:一、软件环境的搭建OpenBSD的安装就不罗嗦了,重点是分区的部分,推荐/var/mysql、/var/log、/var/mail、/var/nginx这几个目录单独分区,并给予足够的空间。
系统安装的最后询问是否默认启动Ssh服务时回答”n”。
安装必须的软件包:export PKG_PATH=ftp:///pub/OpenBSD/4.4/packages/i386/pkg_add wget mysql-server php5-fastcgi php5-gd-5.2.6-no_x11 php5-mysql phpMyAdmin lighttpd-1.4.19p3 nginx pecl-APC装完后按提示做连接并创建PHP工作目录:ln -s /var/www/conf/modules.sample/php5.conf /var/www/conf/modulesln -fs /var/www/conf/php5.sample/apc.ini /var/www/conf/php5/apc.iniln -fs /var/www/conf/php5.sample/gd.ini /var/www/conf/php5/gd.iniln -fs /var/www/conf/php5.sample/mbstring.ini /var/www/conf/php5/mbstring.iniln -fs /var/www/conf/php5.sample/mcrypt.ini /var/www/conf/php5/mcrypt.ini ln -fs /var/www/conf/php5.sample/mysql.ini /var/www/conf/php5/mysql.ini mkdir /var/www/tmpchmod 0777 /var/www/tmpmkdir /var/nginx/html/pma/cp -rf /var/www/phpMyAdmin/* /var/nginx/html/pma/vi /etc/login.conf跳到最后,加入MySQL所需的修改:引用:mysql:\:openfiles-cur=2048:\:openfiles-max=4096:\:tc=daemon:使修改生效:cap_mkdb /etc/login.conf安装数据库:/usr/local/bin/mysql_install_db二、修改各软件的配置文件修改nginx的默认配置文件:vi /etc/nginx/nginx.conf增大nginx的并发连接数:引用:worker_connections 51200;加入对.php文件的支持:引用: location / {root /var/nginx/html;index index.php index.html index.htm;}(加入index.php)将下面这段前面的注释都去掉,改成:引用: location ~ \.php$ {root html;fastcgi_pass 127.0.0.1:9000;fastcgi_index index.php;fastcgi_param SCRIPT_FILENAME /var/nginx/html$fastcgi_script_name; include fastcgi_params;}注意上面第五行,这个部分原来是/scripts,改成/var/nginx/html。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
PHP MySQL 简介MySQL 函数允许您访问MySQL 数据库服务器。
安装为了能够顺利的使用本类函数,必须在编译PHP 时添加对MySQL 的支持。
编译时,只要使用--with-mysql[=DIR] 配置选项即可,其中可选的[DIR] 指向MySQL 的安装目录。
虽然本MySQL 扩展库兼容MySQL 4.1.0 及其以后版本,但是它不支持这些版本提供的额外功能。
要使用这些功能,请使用MySQLi 扩展库。
如果要同时安装mysql 扩展库和mysqli 扩展库,必须使用同一个客户端库以避免任何冲突。
在Linux 系统上安装PHP 4默认开启了--with-mysql 选项。
此默认行为可以用--without-mysql 配置选项来禁止。
如果启用MySQL 而不指定安装目录的话,PHP 将使用绑定的MySQL 客户端连接库。
还有其它应用程序使用MySQL(例如auth-mysql)的用户不要用绑定的库,而要指定MySQL 的安装目录,如这样:--with-mysql=/path/to/mysql。
这将强制PHP 使用随MySQL 安装的客户端连接库,就可以避免任何冲突。
PHP 5+MySQL 默认未启用,也没有绑定的MySQL 库。
使用--with-mysql[=DIR] 配置选项来加入MySQL 的支持。
可以从MySQL下载头文件和库。
在Windows 系统上安装PHP 4PHP MySQL 扩展已经编译入PHP。
PHP 5+MySQL 默认未启用,因此必须在php.ini 中激活php_mysql.dll 动态连接库。
此外,PHP 还需要访问MySQL 客户端连接库。
PHP 的Windows 发行版包括了一个libmysql.dll,为了让PHP 能和MySQL 对话,此文件必须放在Windows 的系统路径PATH 中。
要激活任何PHP 扩展库(例如php_mysql.dll),PHP 指令extension_dir 要被设为PHP 扩展库所在的目录。
PHP 5 下extension_dir 取值的一个例子是c:\php\ext。
注释:如果启动web 服务器时出现类似如下的错误:"Unable to load dynamic library './php_mysql.dll'",这是因为系统找不到php_mysql.dll 和/ 或libmysql.dll。
Runtime 配置MySQL 函数的行为受到php.ini 中设置的影响。
MySQL 配置选项:名称默认描述可更改mysql.allow_persistent "1" 是否允许MySQL 的持久连接。
PHP_INI_SYSTEM mysql.max_persistent "-1" 每个进程中最大的持久连接数目。
PHP_INI_SYSTEM mysql.max_links "-1" 每个进程中最大的连接数,包括持久连接。
PHP_INI_SYSTEM mysql.trace_mode "0" 跟踪模式。
从PHP 4.3.0 起可用。
PHP_INI_ALL mysql.default_port NULL 指定默认连接数据库的TCP 端口号。
PHP_INI_ALL mysql.default_socket NULL 默认的socket 名称。
PHP 4.0.1起可用。
PHP_INI_ALL mysql.default_host NULL 默认的服务器地址。
不适用于SQL安全模式。
PHP_INI_ALL mysql.default_user NULL 默认使用的用户名。
不适用于SQL安全模式。
PHP_INI_ALL mysql.default_password NULL 默认使用的密码。
不适用于SQL安全模式。
PHP_INI_ALL mysql.connect_timeout "60" 连接超时秒数。
PHP_INI_ALL资源类型在MySQL 模块中使用了两种资源类型。
第一种是数据库的连接句柄,第二种是SQL 查询返回的结果集。
PHP MySQL 函数PHP:指示支持该函数的最早的PHP 版本。
mysql_client_encoding()返回当前连接的字符集的名称 4 mysql_close()关闭非持久的MySQL 连接。
3 mysql_connect()打开非持久的MySQL 连接。
3 mysql_create_db() 不赞成。
新建MySQL 数据库。
使用mysql_query() 代替。
3 mysql_data_seek()移动记录指针。
3 mysql_db_name()从对mysql_list_dbs() 的调用返回数据库名称。
33 mysql_db_query()不赞成。
发送一条MySQL 查询。
使用mysql_select_db() 和mysql_query() 代替。
mysql_drop_db()3不赞成。
丢弃(删除)一个MySQL 数据库。
使用mysql_query() 代替。
mysql_errno()返回上一个MySQL 操作中的错误信息的数字编码。
3 mysql_error()返回上一个MySQL 操作产生的文本错误信息。
3 mysql_escape_string()4不赞成。
转义一个字符串用于mysql_query。
使用mysql_real_escape_string() 代替。
mysql_fetch_array()从结果集中取得一行作为关联数组,或数字数组,或二者兼有。
3 mysql_fetch_assoc()从结果集中取得一行作为关联数组。
4 mysql_fetch_field()从结果集中取得列信息并作为对象返回。
3 mysql_fetch_lengths()取得结果集中每个字段的内容的长度。
3 mysql_fetch_object()从结果集中取得一行作为对象。
3 mysql_fetch_row()从结果集中取得一行作为数字数组。
3 mysql_field_flags()从结果中取得和指定字段关联的标志。
3 mysql_field_len()返回指定字段的长度。
3 mysql_field_name()取得结果中指定字段的字段名。
3 mysql_field_seek()将结果集中的指针设定为指定的字段偏移量。
3 mysql_field_table()取得指定字段所在的表名。
3mysql_field_type()取得结果集中指定字段的类型。
3 mysql_free_result()释放结果内存。
3 mysql_get_client_info()取得MySQL 客户端信息。
4 mysql_get_host_info()取得MySQL 主机信息。
4 mysql_get_proto_info()取得MySQL 协议信息。
4 mysql_get_server_info()取得MySQL 服务器信息。
4 mysql_info()取得最近一条查询的信息。
4 mysql_insert_id()取得上一步INSERT 操作产生的ID。
3 mysql_list_dbs()列出MySQL 服务器中所有的数据库。
3 mysql_list_fields()3不赞成。
列出MySQL 结果中的字段。
使用mysql_query() 代替。
mysql_list_processes()列出MySQL 进程。
43 mysql_list_tables()不赞成。
列出MySQL 数据库中的表。
使用Use mysql_query() 代替。
mysql_num_fields()取得结果集中字段的数目。
3 mysql_num_rows()取得结果集中行的数目。
3 mysql_pconnect()打开一个到MySQL 服务器的持久连接。
3 mysql_ping()Ping 一个服务器连接,如果没有连接则重新连接。
4 mysql_query()发送一条MySQL 查询。
3 mysql_real_escape_string()转义SQL 语句中使用的字符串中的特殊字符。
4 mysql_result()取得结果数据。
3 mysql_select_db()选择MySQL 数据库。
3 mysql_stat()取得当前系统状态。
4 mysql_tablename() 不赞成。
取得表名。
使用mysql_query() 代替。
3 mysql_thread_id()返回当前线程的ID。
4 mysql_unbuffered_query()向MySQL 发送一条SQL 查询(不获取/ 缓存结果)。
4 PHP MySQL 常量在PHP 4.3.0 以后的版本中,允许在mysql_connect() 函数和mysql_pconnect() 函数中指定更多的客户端标记:PHP:指示支持该常量的最早的PHP 版本。
mysql_fetch_array() 函数使用一个常量来表示所返回数组的类型:。