Home Database Mysql Tutorial Mysql数据库中英对照表_MySQL

Mysql数据库中英对照表_MySQL

Jun 01, 2016 pm 01:48 PM
Database Table

bitsCN.com

--语 句 功 能 
--数据操作 
SELECT --从数据库表中检索数据行和列 
INSERT --向数据库表添加新数据行
DELETE --从数据库表中删除数据行 
UPDATE --更新数据库表中的数据 
--数据定义 
CREATE TABLE--创建一个数据库表 
DROP TABLE --从数据库中删除表 
ALTER TABLE --修改数据库表结构 
CREATE VIEW--创建一个视图 
DROP VIEW --从数据库中删除视图 
CREATE INDEX --为数据库表创建一个索引 
DROP INDEX--从数据库中删除索引 
CREATE PROCEDURE --创建一个存储过程 
DROP PROCEDURE --从数据库中删除存储过程
CREATE TRIGGER --创建一个触发器 
DROP TRIGGER --从数据库中删除触发器 
CREATE SCHEMA--向数据库添加一个新模式 
DROP SCHEMA --从数据库中删除一个模式 
CREATE DOMAIN --创建一个数据值域
ALTER DOMAIN --改变域定义 
DROP DOMAIN --从数据库中删除一个域 
--数据控制 
GRANT--授予用户访问权限 
DENY --拒绝用户访问 
REVOKE --解除用户访问权限 
--事务控制 
COMMIT--结束当前事务 
ROLLBACK --中止当前事务 
SET TRANSACTION --定义当前事务数据访问特征 
--程序化SQL
DECLARE --为查询设定游标 
EXPLAN --为查询描述数据访问计划 
OPEN --检索查询结果打开一个游标 
FETCH--检索一行查询结果 
CLOSE --关闭游标 
PREPARE --为动态执行准备SQL 语句 
EXECUTE --动态地执行SQL语句 
DESCRIBE --描述准备好的查询 
---局部变量 
declare @id char(10) 
--set @id ='10010001' 
select @id = '10010001' 
---全局变量 
---必须以@@开头 
--IF ELSE
declare @x int @y int @z int 
select @x = 1 @y = 2 @z=3 
if @x > @y
print 'x > y' --打印字符串'x > y' 
else if @y > @z 
print 'y >z' 
else print 'z > y' 
--CASE 
use pangu 
update employee
set e_wage = 
case 
when job_level = '1' then e_wage*1.08 
whenjob_level = '2' then e_wage*1.07 
when job_level = '3' then e_wage*1.06
else e_wage*1.05 
end 
--WHILE CONTINUE BREAK 
declare @x int @yint @c int 
select @x = 1 @y=1 
while @x begin 
print @x--打印变量x 的值 
while @y begin 
select @c = 100*@x + @y 
print@c --打印变量c 的值 
select @y = @y + 1 
end 
select @x = @x + 1 
select@y = 1 
end 
--WAITFOR 
--例 等待1 小时2 分零3 秒后才执行SELECT 语句 
waitfordelay '01:02:03' 
select * from employee 
--例 等到晚上11 点零8 分后才执行SELECT 语句
waitfor time '23:08:00' 
select * from employee 
***SELECT***
select *(列名) from table_name(表名) where column_name operator value 
exMysql数据库中英对照表_MySQL宿主)
select * from stock_information where stockid = str(nid) 
stockname ='str_name' 
stockname like '% find this %' 
stockname like '[a-zA-Z]%'--------- ([]指定值的范围) 
stockname like '[^F-M]%' --------- (^排除指定范围)
--------- 只能在使用like关键字的where子句中使用通配符) 
or stockpath = 'stock_path' 
orstocknumber and stockindex = 24 
not stocksex = 'man'
stocknumber between 20 and 100 
stocknumber in(10,20,30) 
order bystockid desc(asc) --------- 排序,desc-降序,asc-升序 
order by 1,2 --------- by列号
stockname = (select stockname from stock_information where stockid = 4)
--------- 子查询 
--------- 除非能确保内层select只返回一个行的值, 
---------否则应在外层where子句中用一个in限定符 
select distinct column_name form table_name ---------distinct指定检索独有的列值,不重复 
select stocknumber ,"stocknumber + 10" = stocknumber +10 from table_name 
select stockname , "stocknumber" = count(*) fromtable_name group by stockname 
--------- group by 将表按行分组,指定列中有相同的值 
havingcount(*) = 2 --------- having选定指定的组 
select * 
from table1, table2
where table1.id *= table2.id -------- 左外部连接,table1中有的而table2中没有得以null表示
table1.id =* table2.id -------- 右外部连接 
select stockname from table1
union [all] ----- union合并查询结果集,all-保留重复行 
select stockname from table2
***insert*** 
insert into table_name (Stock_name,Stock_number) value("xxx","xxxx") 
value (select Stockname , Stocknumber fromStock_table2)---value为select语句 
***update*** 
update table_name setStockname = "xxx" [where Stockid = 3] 
Stockname = default 
Stockname =null 
Stocknumber = Stockname + 4 
***delete*** 
delete from table_namewhere Stockid = 3 
truncate table_name ----------- 删除表中所有行,仍保持表的完整性 
droptable table_name --------------- 完全删除表 
***alter table*** --- 修改数据库表结构
alter table database.owner.table_name add column_name char(2) null .....
sp_help table_name ---- 显示表已有特征 
create table table_name (name char(20),age smallint, lname varchar(30)) 
insert into table_name select .........----- 实现删除列的方法(创建新表) 
alter table table_name drop constraintStockname_default ---- 删除Stockname的default约束 
***function(/*常用函数*/)***
----统计函数---- 
AVG --求平均值 
COUNT --统计数目 
MAX --求最大值 
MIN --求最小值
SUM --求和 
--AVG 
use pangu 
select avg(e_wage) as dept_avgWage
from employee 
group by dept_id 
--MAX 
--求工资最高的员工姓名 
use pangu
select e_name 
from employee 
where e_wage = 
(select max(e_wage)
from employee) 
--STDEV() 
--STDEV()函数返回表达式中所有数据的标准差 
--STDEVP()
--STDEVP()函数返回总体标准差 
--VAR() 
--VAR()函数返回表达式中所有值的统计变异数 
--VARP()
--VARP()函数返回总体变异数 
----算术函数---- 
/***三角函数***/
SIN(float_expression) --返回以弧度表示的角的正弦 
COS(float_expression)--返回以弧度表示的角的余弦 
TAN(float_expression) --返回以弧度表示的角的正切
COT(float_expression) --返回以弧度表示的角的余切 
/***反三角函数***/
ASIN(float_expression) --返回正弦是FLOAT 值的以弧度表示的角 
ACOS(float_expression)--返回余弦是FLOAT 值的以弧度表示的角 
ATAN(float_expression) --返回正切是FLOAT 值的以弧度表示的角
ATAN2(float_expression1,float_expression2) 
--返回正切是float_expression1/float_expres-sion2的以弧度表示的角 
DEGREES(numeric_expression)
--把弧度转换为角度返回与表达式相同的数据类型可为 
--INTEGER/MONEY/REAL/FLOAT 类型
RADIANS(numeric_expression) --把角度转换为弧度返回与表达式相同的数据类型可为
--INTEGER/MONEY/REAL/FLOAT 类型 
EXP(float_expression) --返回表达式的指数值
LOG(float_expression) --返回表达式的自然对数值 
LOG10(float_expression)--返回表达式的以10为底的对数值 
SQRT(float_expression) --返回表达式的平方根 
/***取近似值函数***/
CEILING(numeric_expression) --返回>=表达式的最小整数返回的数据类型与表达式相同可为
--INTEGER/MONEY/REAL/FLOAT 类型 
FLOOR(numeric_expression) --返回 --INTEGER/MONEY/REAL/FLOAT 类型
ROUND(numeric_expression) --返回以integer_expression 为精度的四舍五入值返回的数据
--类型与表达式相同可为INTEGER/MONEY/REAL/FLOAT 类型 
ABS(numeric_expression)--返回表达式的绝对值返回的数据类型与表达式相同可为 
--INTEGER/MONEY/REAL/FLOAT 类型
SIGN(numeric_expression) --测试参数的正负号返回0 零值1 正数或-1 负数返回的数据类型
--与表达式相同可为INTEGER/MONEY/REAL/FLOAT 类型 
PI() --返回值为π 即3.1415926535897936
RAND([integer_expression]) --用任选的[integer_expression]做种子值得出0-1 间的随机浮点数
----字符串函数---- 
ASCII() --函数返回字符表达式最左端字符的ASCII 码值 
CHAR() --函数用于将ASCII码转换为字符 
--如果没有输入0 ~ 255 之间的ASCII 码值CHAR 函数会返回一个NULL 值 
LOWER()--函数把字符串全部转换为小写 
UPPER() --函数把字符串全部转换为大写 
STR() --函数把数值型数据转换为字符型数据
LTRIM() --函数把字符串头部的空格去掉 
RTRIM() --函数把字符串尾部的空格去掉
LEFT(),RIGHT(),SUBSTRING() --函数返回部分字符串 
CHARINDEX(),PATINDEX()--函数返回字符串中某个指定的子串出现的开始位置 
SOUNDEX() --函数返回一个四位字符码
--SOUNDEX函数可用来查找声音相似的字符串但SOUNDEX函数对数字和汉字均只返回0 值 
DIFFERENCE()--函数返回由SOUNDEX 函数返回的两个字符表达式的值的差异 
--0 两个SOUNDEX 函数返回值的第一个字符不同 
--1两个SOUNDEX 函数返回值的第一个字符相同 
--2 两个SOUNDEX 函数返回值的第一二个字符相同 
--3 两个SOUNDEX函数返回值的第一二三个字符相同 
--4 两个SOUNDEX 函数返回值完全相同 
QUOTENAME() --函数返回被特定字符括起来的字符串
/*select quotename('abc', '{') quotename('abc') 
运行结果如下
----------------------------------{ 
{abc} [abc]*/ 
REPLICATE()--函数返回一个重复character_expression 指定次数的字符串 
/*select replicate('abc', 3)replicate( 'abc', -2) 
运行结果如下 
----------- ----------- 
abcabcabcNULL*/ 
REVERSE() --函数将指定的字符串的字符排列顺序颠倒 
REPLACE() --函数返回被替换了指定子串的字符串
/*select replace('abc123g', '123', 'def') 
运行结果如下 
---------------------- 
abcdefg*/ 
SPACE() --函数返回一个有指定长度的空白字符串 
STUFF()--函数用另一子串替换字符串指定位置长度的子串 
----数据类型转换函数---- 
CAST() 函数语法如下 
CAST() ( AS [ length ]) 
CONVERT() 函数语法如下
CONVERT() ( [ length ], [, style])
select cast(100+99 as char) convert(varchar(12), getdate()) 
运行结果如下
----日期函数---- 
DAY() --函数返回date_expression 中的日期值 
MONTH()--函数返回date_expression 中的月份值 
YEAR() --函数返回date_expression 中的年份值 
DATEADD( , ,
--函数返回指定日期date加上指定的额外日期间隔number 产生的新日期 
DATEDIFF( , ,
--函数返回两个指定日期在datepart 方面的不同之处 
DATENAME( ,) --函数以字符串的形式返回日期的指定部分 
DATEPART( ,) --函数以整数值的形式返回日期的指定部分 
GETDATE() --函数以DATETIME 的缺省格式返回系统当前的日期和时间
----系统函数---- 
APP_NAME() --函数返回当前执行的应用程序的名称 
COALESCE()--函数返回众多表达式中第一个非NULL 表达式的值 
COL_LENGTH( ,) --函数返回表中指定字段的长度值 
COL_NAME( ,) --函数返回表中指定字段的名称即列名 
DATALENGTH() --函数返回数据表达式的数据的实际长度
DB_ID(['database_name']) --函数返回数据库的编号 
DB_NAME(database_id) --函数返回数据库的名称
HOST_ID() --函数返回服务器端计算机的名称 
HOST_NAME() --函数返回服务器端计算机的名称 
IDENTITY([, seed increment]) [AS column_name]) 
--IDENTITY()函数只在SELECT INTO 语句中使用用于插入一个identity column列到新表中 
/*select identity(int, 1, 1)as column_name 
into newtable 
from oldtable*/ 
ISDATE()--函数判断所给定的表达式是否为合理日期 
ISNULL( ,) --函数将表达式中的NULL 值用指定值替换 
ISNUMERIC()--函数判断所给定的表达式是否为合理的数值 
NEWID() --函数返回一个UNIQUEIDENTIFIER 类型的数值 
NULLIF(,
--NULLIF 函数在expression1与expression2 相等时返回NULL 值若不相等时则返回expression1 的值

来路地址:http://superman.php100.com/apps-htm-q-diary-a-detail-did-7151.html

bitsCN.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to create and manage database tables using PHP How to create and manage database tables using PHP Sep 09, 2023 pm 04:48 PM

How to use PHP to create and manage database tables With the rapid development of the Internet, databases have become an indispensable part of various websites and applications. In PHP, we can use a database management system (DBMS) such as MySQL to create and manage database tables. This article will teach you how to use PHP to implement this function, with corresponding code examples. Connect to the database First, we need to connect to the database in PHP. You can use the mysqli extension or PDO provided by PHP to achieve this function.

What are the differences between database views and tables? What are the differences between database views and tables? Sep 04, 2023 pm 03:13 PM

The differences between database views and tables are: 1. A table is a physical structure used to store data in a database, while a view is just a query result set based on a table or multiple tables; 2. A table is the physical storage unit of data, and a view only provides Rules for viewing and operating table data; 3. Views provide an advanced security mechanism for the database, and tables have no security mechanism; 4. Views are abstractions of tables; 5. Views can combine multiple tables in queries, and tables can only query a single table; 6. Tables are permanent structures in the database, views are not; 7. Views can create views with the same name, but tables cannot create tables with the same name, etc.

How to distinguish database views and tables How to distinguish database views and tables Aug 22, 2023 am 11:27 AM

Database views and tables are two different concepts in the database, with different characteristics and uses. A table is an entity that actually stores data in the database, while a view is a virtual table derived from one or more tables, used to specify way to present and manipulate data. Tables have higher data persistence, while views provide more flexible and convenient data access.

PHP and PDO: How to perform modification and renaming of database tables PHP and PDO: How to perform modification and renaming of database tables Jul 28, 2023 pm 10:42 PM

PHP and PDO: How to modify and rename database tables. As applications develop and requirements change, we often need to modify and rename tables in the database. In PHP, we can use the PDO (PHPDataObjects) extension library to perform these operations. This article will introduce how to use PDO to perform modification and renaming of database tables, and provide code examples. First, we need to make sure we have successfully connected to the database. Assume that we have established a connection with the database using PDO

What are the differences between database views and tables? What are the differences between database views and tables? Aug 22, 2023 am 11:15 AM

There are five differences between database views and tables in the database: 1. Views do not store data, but tables are the objects that actually store data; 2. The data in the view is a virtual table, and the data in the table can come from multiple sources; 3. The view inherits the structure of the query statement, while the table has its own structural definition; 4. The view cannot be updated, while the table allows direct operations on it; 5. The view is based on the permissions of the underlying table, and the table has its own access permissions.

Data export: customized database table Data export: customized database table Sep 02, 2023 pm 06:01 PM

As mentioned in the first article in this series, one of the main problems with custom database tables is that they are not handled by existing import and export handlers. This article aims to address this problem, but it should be noted that there is currently no fully satisfactory solution. Let’s consider two scenarios: The custom table references a native WordPress table The custom table is completely independent of the native table The “worst case” is the first case. Take a custom table that saves user activity logs as an example. It references the user ID, object ID, and object type - all of which reference data stored in native WordPress tables. Now imagine that someone wants to import all the data from their WordPress website into a second website. For example, completely

Optimize MySQL table structure to solve connection problems Optimize MySQL table structure to solve connection problems Jun 30, 2023 pm 01:04 PM

MySQL connection problem: How to optimize the database table structure? Database connections are a very important part when developing applications. When we use MySQL database, correctly optimizing the database table structure can improve query and connection performance, thereby improving application performance and response speed. This article will introduce some methods to optimize the database table structure to solve MySQL connection problems. 1. Reasonably design the table structure. When designing the database table structure, it is necessary to reasonably design the relationship between tables according to the needs of the application and reduce the amount of data.

What is the relationship between tables and databases What is the relationship between tables and databases Aug 28, 2023 am 09:15 AM

Tables are the way data is stored in the database, and the database is the overall container and management system for data. Tables use the functions provided by the database to perform operations such as creation, query, update, and deletion to meet user needs for data.

See all articles