markdown [MySQL Essential Training] #MySQL #Database

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了markdown [MySQL Essential Training] #MySQL #Database相关的知识,希望对你有一定的参考价值。

对于一个表单,如果直接使用Insert into命令,可能会出现duplicate key的情况,导致代码无法执行。
此时,有以下三种命令可以使用:
1. INSERT IGNORE INTO:该命令会忽略有重复key的记录,不进行row插入。
2. ```INSERT INTO tableName (columns) VALUES (records1), (records2)… ON DUPLICATE KEY UPDATE column1=VALUES(relatedColumn)/data```
3. REPLACE INTO:该命令是发现重复key时会先DELETE该record,然后重新使用INSERT INTO插入。若无重复key,则直接插入record。
- Create: 
```sql
CREATE TABLE TableName(ColumnName  DataType, …);
```
- (Read)Select: 
```sql    
SELECT ColumnName,… FROM TableName ;
```
- Update: 
```sql  
UPDATE TableName SET ColumnName = realData ;
```
- Delete: 
```sql 
DELETE FROM TableName [where conditions] ;
```
Once unique constraint is set on a column, MySQL will initiate an index for that column to enforce this constraint.
Once into a certain query,  Function NOW() will only be executed once while SYSDATE() will be executed every time called.
A certain query means in the same semicolon separated sentence.
Regular Expression starts with a ^ sign representing the beginning of a certain string, and end with a $ sign representing the end of a certain string.
E.G. '^.[a-e].*$' returns strings in which the second place is a character ranging from 'a' to 'e'.
The way of representing space in REGEXP is [[:space:]].
In MySQL, it is a good way to present results in fixed number pages using LIMIT and OFFSET in SQL.
```sql
SELECT * FROM TableName ORDER BY ColumnName LIMIT Number OFFSET Number.
```
```sql
DROP TABLE TableName
DROP TABLE IF EXISTS TableName
DROP DATABASE DatabaseName
DROP DATABASE IF EXISTS DatabaseName
```

以上是关于markdown [MySQL Essential Training] #MySQL #Database的主要内容,如果未能解决你的问题,请参考以下文章

markdown essential-javascript-links.md

markdown keeping_unit_test_setup_essential.md

MySQL essential与MySQL

mysql-essential-5.1.55-win32 安装

MySQL essential版本和普通版本有啥区别

Mysql5.1.32服务的安装详细介绍