Home >Database >Mysql Tutorial >MySQL总结之SQL语句的应用

MySQL总结之SQL语句的应用

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-07 17:01:281009browse

创建一个表:mysqlgt; CREATE TABLE students (-gt; sno CHAR(10) PRIMARY KEY,-gt; sname CHAR(8) NOT NULL,-gt; ssex CHAR

创建一个表:

mysql> CREATE TABLE students (

-> sno CHAR(10) PRIMARY KEY,

-> sname CHAR(8) NOT NULL,

-> ssex CHAR(1) NOT NULL CHECK(ssex = 'F' OR ssex = 'M'),

-> sage INT     NOT NULL,

-> sdept CHAR(20) DEFAULT 'Computer'

-> )

-> ;

MySQL

MySQl所支持的字符类型:

MySQL

修改表结构:

mysql> ALTER TABLE students CHANGE sage sage INT UNSIGNED;

MySQL

mysql> ALTER TABLE students ADD Grade1 INT NOT NULL  DEFAULT '1';

MySQL

删除一个字段:

mysql> ALTER TABLE students DROP Grade1 ;

表重命名:

mysql> ALTER TABLE students RENAME students2;

数据库存储引擎类型:

存储引擎:相当于一个插件,,MySQL跟存储在磁盘上的文件进行交互的接口。

*************************** 1. row ***************************

Engine: InnoDB(行级别锁 粒度比较小)

Support: YES

Comment: Supports transactions, row-level locking, and foreign keys

Transactions: YES

XA: YES

Savepoints: YES

*************************** 2. row ***************************

Engine: MRG_MYISAM

Support: YES

Comment: Collection of identical MyISAM tables

Transactions: NO

XA: NO

Savepoints: NO

*************************** 3. row ***************************

Engine: BLACKHOLE

Support: YES

Comment: /dev/null storage engine (anything you write to it disappears)

Transactions: NO

XA: NO

Savepoints: NO

*************************** 4. row ***************************

Engine: CSV

Support: YES

Comment: CSV storage engine

Transactions: NO

XA: NO

Savepoints: NO

*************************** 5. row ***************************

Engine: MEMORY

Support: YES

Comment: Hash based, stored in memory, useful for temporary tables

Transactions: NO

XA: NO

Savepoints: NO

*************************** 6. row ***************************

Engine: FEDERATED

Support: NO

Comment: Federated MySQL storage engine

Transactions: NULL

XA: NULL

Savepoints: NULL

*************************** 7. row ***************************

Engine: ARCHIVE

Support: YES

Comment: Archive storage engine

Transactions: NO

XA: NO

Savepoints: NO

*************************** 8. row ***************************

linux

Statement:
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