mysql数据库语法

一、查询

1、获取mysql的所有数据库名

select schema_name from information_schema.schemata;

在这里插入图片描述
2、获取指定数据库dev所有表名

select table_name from information_schema.tables where table_schema='dev';

在这里插入图片描述
3、获取数据库dev中以’case_data’开头的表名

select table_name from information_schema.tables where table_name like 'case_data%' and table_schema='dev';

4、获取数据库dev中attach表的列信息

select column_name from information_schema.columns where table_name = 'attach' and table_schema='dev';

在这里插入图片描述

二、删除

1、清空数据库表数据
删除数据库表area所有数据并清除索引

truncate area;

删除数据库表area所有数据不清除索引

delete from area;

三、更新

三、更新

四、增加

1、创建数据库temp

CREATE DATABASE `temp` CHARACTER SET 'utf8' COLLATE 'utf8_general_ci';

2、创建数据库表bed

CREATE TABLE `bed` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键id',
  `name` varchar(128) NOT NULL DEFAULT '' COMMENT '名称',
  `create_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间',
  `update_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '更新时间',
  `cash_charge` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '价格',
  `status` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '0-正常 1-禁用',
  PRIMARY KEY (`id`) USING BTREE,
  KEY `cash_charge` (`cash_charge`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=531865 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='家具表';
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

学无止境gwx

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值