“mysql”表的定义有注释吗?

“mysql”表的定义有注释吗?,第1张

有的,用如下方法:

1、创建表的时候写注释

create table test1

(

field_name int comment '字段的注释'

)comment='表的注释';

2、修改表的注释

alter table test1 comment '修改后的表的注释';

3、修改字段的注释

alter table test1 modify column field_name int comment '修改后的字段注释';

--注意:字段名和字段类型照写就行

4、查看表注释的方法

--在生成的SQL语句中看

show create table test1;

--在元数据的表里面看

use information_schema;

select * from TABLES where TABLE_SCHEMA='my_db' and TABLE_NAME='test1' \G

5、查看字段注释的方法

--show

show full columns from test1;

--在元数据的表里面看

select * from COLUMNS where TABLE_SCHEMA='my_db' and TABLE_NAME='test1' \G

1、使用 create table 语句可完成对表的创建, create table 的创建形式:

create table 表名称(列声明)

以创建 people 表为例, 表中将存放 学号(id)、姓名(name)、性别(sex)、年龄(age) 这些内容:

create table people(

id int unsigned not null auto_increment primary key,

name char(8) not null,

sex char(4) not null,

age tinyint unsigned not null

)

其中,auto_increment就可以使Int类型的id字段每次自增1。

2、向表中插入数据使用insert 语句。

insert 语句可以用来将一行或多行数据插到数据库表中, 使用的一般形式如下:

insert [into] 表名 [(列名1, 列名2, 列名3, ...)] values (值1, 值2, 值3, ...)

其中 [] 内的内容是可选的, 例如, 要给上步中创建的people 表插入一条记录, 执行语句:

insert into people(name,sex,age) values( "张三", "男", 21 )

3、想要查询是否插入成功,可以通过select 查询语句。形式如下:

select * from people;

扩展资料:

当mysql大批量插入数据的时候使用insert into就会变的非常慢, mysql提高insert into 插入速度的方法有三种:

1、第一种插入提速方法:

如果数据库中的数据已经很多(几百万条), 那么可以 加大mysql配置中的 bulk_insert_buffer_size,这个参数默认为8M

举例:bulk_insert_buffer_size=100M;

2、第二种mysql插入提速方法:

改写所有 insert into 语句为 insert delayed into

这个insert delayed不同之处在于:立即返回结果,后台进行处理插入。

3、第三个方法: 一次插入多条数据:

insert中插入多条数据,举例:

insert into table values('11','11'),('22','22'),('33','33')...


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/8600504.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-18
下一篇 2023-04-18

发表评论

登录后才能评论

评论列表(0条)

保存