1、创建数据库 create database database-name; 2、删除数据库 drop database database-name; 3、创建新表 create table table-name(col-name type,..... ); 4、使用旧表创建新表 create table tab_new like tab_old; 5、删除表 drop table table-name; 6、
1、创建数据库
create database database-name;
2、删除数据库
drop database database-name;
3、创建新表
create table table-name(col-name type,..... );
4、使用旧表创建新表
create table tab_new like tab_old;
5、删除表
drop table table-name;
6、增加列
alert table table-name add column col-name type;
7、增加主键
alert table table-name add primary key (col-name);
8、删除主键
alert table table-name drop primary key (col-name);
9、创建索引
create [unique] index index-name on table-name(col-name,...)
alert table table-name add index index-name(col-name)
10、删除索引
drop index index-name on table-name;
11、基本sql语句
查询:
select * from table-name where 条件
插入:
insert into table-name(col-name,...) values (value1,...);
删除:
delete from table-name where 条件;
更新:
update table-name set col-name = value where 条件;
模糊查询:
select * from table-name where col-name like '%a%'
select * from table-name where col-name like 'a%'
select * from table-name where col-name like '%a'
select * from table-name where instr(col-name,'a') > 0
select * from table-name where instr(col-name,'a') = 1
select * from table-name where instr(col-name,'a') = 0
排序:
select * from table-name order by col-name desc(asc);
总数:
select count(*) from table-name where 条件
求和:
select sum(col-name) from table-name
平均:
select avg(col-name) from table-name
最大:
select max(col-name) from table-name
最小:
select min(col-name) from table-name;
12、连接
左连接:
left join :结果集中既包括连接表的匹配行,也包括左连接表的所有行
右连接:
right join:结果集中既包括连接表的匹配行,也包括右连接表的所有行
全外连接:
full/cross (outer) join:不仅包括符合连接表的匹配行,还包括两个连接表中的所有记录
13、修改数据库名字
sp_renamedb ‘old_name’ , 'new_name'
14、in的用法
select * from table-name where col-name [not] in (,,,);

本篇文章给大家带来了关于mysql的相关知识,其中主要介绍了关于架构原理的相关内容,MySQL Server架构自顶向下大致可以分网络连接层、服务层、存储引擎层和系统文件层,下面一起来看一下,希望对大家有帮助。

mysql的msi与zip版本的区别:1、zip包含的安装程序是一种主动安装,而msi包含的是被installer所用的安装文件以提交请求的方式安装;2、zip是一种数据压缩和文档存储的文件格式,msi是微软格式的安装包。

方法:1、利用right函数,语法为“update 表名 set 指定字段 = right(指定字段, length(指定字段)-1)...”;2、利用substring函数,语法为“select substring(指定字段,2)..”。

在mysql中,可以利用char()和REPLACE()函数来替换换行符;REPLACE()函数可以用新字符串替换列中的换行符,而换行符可使用“char(13)”来表示,语法为“replace(字段名,char(13),'新字符串') ”。

转换方法:1、利用cast函数,语法“select * from 表名 order by cast(字段名 as SIGNED)”;2、利用“select * from 表名 order by CONVERT(字段名,SIGNED)”语句。

本篇文章给大家带来了关于mysql的相关知识,其中主要介绍了关于MySQL复制技术的相关问题,包括了异步复制、半同步复制等等内容,下面一起来看一下,希望对大家有帮助。

在mysql中,可以利用REGEXP运算符判断数据是否是数字类型,语法为“String REGEXP '[^0-9.]'”;该运算符是正则表达式的缩写,若数据字符中含有数字时,返回的结果是true,反之返回的结果是false。

在mysql中,可利用“ALTER TABLE 表名 DROP INDEX unique key名”语句来删除unique key;ALTER TABLE语句用于对数据进行添加、删除或修改操作,DROP INDEX语句用于表示删除约束操作。


热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

AI Hentai Generator
免费生成ai无尽的。

热门文章

热工具

SublimeText3 Mac版
神级代码编辑软件(SublimeText3)

适用于 Eclipse 的 SAP NetWeaver 服务器适配器
将Eclipse与SAP NetWeaver应用服务器集成。

MinGW - 适用于 Windows 的极简 GNU
这个项目正在迁移到osdn.net/projects/mingw的过程中,你可以继续在那里关注我们。MinGW:GNU编译器集合(GCC)的本地Windows移植版本,可自由分发的导入库和用于构建本地Windows应用程序的头文件;包括对MSVC运行时的扩展,以支持C99功能。MinGW的所有软件都可以在64位Windows平台上运行。

Dreamweaver CS6
视觉化网页开发工具

WebStorm Mac版
好用的JavaScript开发工具