当前位置:Gxlcms > mysql > MySQL总结之SQL语句的应用

MySQL总结之SQL语句的应用

时间:2021-07-01 10:21:17 帮助过:35人阅读

创建一个表: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

人气教程排行