常用mysql命令二

 

① 创建含大文本数据类型的表


create table userclob(

id int auto_increment primary key,
name varchar(30) not null,
note longtext

);

mysql> create table userclob(
    ->
    -> id int auto_increment primary key,
    -> name varchar(30) not null,
    -> note longtext
    ->
    -> );
Query OK, 0 rows affected (0.35 sec)

 

mysql> desc userclob;
+-------+-------------+------+-----+---------+----------------+
| Field | Type        | Null | Key | Default | Extra          |
+-------+-------------+------+-----+---------+----------------+
| id    | int(11)     | NO   | PRI | NULL    | auto_increment |
| name  | varchar(30) | NO   |     | NULL    |                |
| note  | longtext    | YES  |     | NULL    |                |
+-------+-------------+------+-----+---------+----------------+
3 rows in set (0.14 sec)


② 创建含二进制数据类型的表【存取图片,音频等,但若文件太大,建议只用Varchar存取路径,文件直接放硬盘上。】

create table userblob(

id int auto_increment primary key,
name varchar(64) not null,
photo longblob

);

mysql> create table userblob(
    ->
    -> id int auto_increment primary key,
    -> name varchar(64) not null,
    -> photo longblob
    ->
    -> );
Query OK, 0 rows affected (0.14 sec)


mysql> desc userblob;
+-------+-------------+------+-----+---------+----------------+
| Field | Type        | Null | Key | Default | Extra          |
+-------+-------------+------+-----+---------+----------------+
| id    | int(11)     | NO   | PRI | NULL    | auto_increment |
| name  | varchar(64) | NO   |     | NULL    |                |
| photo | longblob    | YES  |     | NULL    |                |
+-------+-------------+------+-----+---------+----------------+
3 rows in set (0.02 sec)

 

 

 

 

 

 

 

你可能感兴趣的:(mysql)