• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录

cokelike

  • 博客园
  • 联系
  • 订阅
  • 管理

公告

View Post

mysql 命令创建表格

mysql数据类型参考菜鸟教程:

https://www.runoob.com/mysql/mysql-data-types.html

显示mysql相关显示命令:

show databases;   #显示数据库创建的数据库名
use [  database name ]; #后 show tables;查看  table 数据信息
describe [  table name ]; #显示表格信息
show   create table [  table name ]; #显示创建的详细信息
select *  from [  table name ]; #查表
select SQL_NO_CACHE *  from [ table name ];  SQL_NO_CACHE 关键字不免缓存查询

创建文件夹

create database text;   #text文件夹

命令创建mysql table `student`:

create table `student`(
`id`  int (4)  not null auto_increment comment  '学号' ,
` name `  varchar (4)  not null default '匿名' comment  '姓名' ,
`sex`  varchar (1)  not null default '男' comment  '性别' ,
`createTime`  timestamp not null default current_timestamp comment  '创建时间' ,
`updateTime`  timestamp not null default current_timestamp no update current_timestamp comment  '修改时间' ,
`8.0版本_time`  TIMESTAMP DEFAULT CURRENT_TIMESTAMP, #`time` TIMESTAMP DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP 插入不会默认更新 INSERT INTO example (name, time) VALUES ('example name', NULL);
`8.0版本_time`  DATETIME DEFAULT CURRENT_TIMESTAMP,
 primary key (`id`)
)engine=innodb   default charset=utf8;

 mysql删除相关命令:

drop table [ table name ]; #删除表格
drop table if exists [ table name ]; #条件删除 table
drop database [ database name ]; #删除 database 数据
truncate [ table name ]; #清空数据
reset query cache; #清除查询缓存
flush hosts; 清除缓存
FLUSH TABLES  WITH READ LOCK 关闭所有打开的表,同时对于所有数据库中的表都加一个读锁,直到显示地执行unlock
UNLOCK TABLES 解锁 table lock

mysql修改命令alter:【of 表格】

alter table [ table name ]  add ` key `  not null default '默认' comment  '注释' ; #添加 table 信息
alter table [ table name ]  drop ` key `; #删除 key of table
alter table [ table name ] rename  as [ table name ]; 给表单从新命名
alter table [ table name ]  modify 'key' char (5)...;相当于修改源数据类
alter table [ table name ] change ` key ` ` key `  varchar (5)....; 相当于重命名

mysql插入数据修改数据:【of 数据】

insert into [ table name ] (` key `,`key1`) value( "?" , "?" ); #插入数据  values ( "" , "" ),( "" , "" )一次性插入数据
update [ table name ]  set ` key `= "" ,`key1`= "" ; #不加 where id=?  or ather change  all 多 key 赋值用逗号隔开
delete from [ table name ]; #不加 where id=?  or ather  delete all auto_increment重新插入数据id以上一次记录开始

 mysql常用查询:

 

SELECT *  FROM files  WHERE fileName  LIKE BINARY '%e%' ; //模糊查询
select *  from files limit 0,5 //pagesize

 

mysql服务命令:

windows:
  mysql -uroot -p
  net stop mysql
  net start mysql
linux:
  systemctl start mysqld 
  systemctl stop mysqld
  systemctl status mysqld

 

posted on 2022-08-20 23:54  cokelike  阅读(167)  评论(0)    收藏  举报

刷新页面返回顶部
 
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3