mysql强制安装参数_mysql安装及相关配置

创建表

create table [if not exist] 'tablename'(

'colname1' int not null auto_increment,

'colsname2' varchar(20) not null,

'colsname3' char(4),

primary key(colname1,colname2),

foreign key(colname2)

)engine = InnoDB default charset =utf8;

删除表

drop table[if exist]'tablename'[restrict | cascade]

约束条件:

1)restrict(默认):如果存在依赖该表的对象,则此表不能删除。

2)cascade:该表删除时没有限制条件,在删除基本表的同时,相关的依赖对象都将一起删除

更改表结构

alter table 表名 add 列表 列数据类型 [after 插入位置];

alter table 表名 change 列名称 列新名称 新数据类型;

alter table 表名 drop 列名称;

增加列

insert into table(列1,列2,列3...) value(值1,值2,值3...)(值1,值2,值3...)(值1,值2,值3...)...

删除行

delete from table where

更新表信息

update table set alary=salary+1 where 按条件更新数据

查询

select [distinct] value as new_vallue

from table new_table

where ___

group by _____

having _____

order by ____ desc / asc

limit _ offset _

左连接: left join tabla_从 on #以主表为主

右连接: right join tabla_从 on #以从表为主

内连接: inner join tabla_从 on #以主从表交集为主

全连接: full join tabla_从 on #以主从表并集为主(mysql目前不支持此种方式)

交集: select no from table_1 intersect select no from table_2 #1交2

并集: select no from table_1 union select no from table_2 #1并2

差集: select no from table_1 except select no from table_2 #1 - 2

运算符:=, <=>, <>, !=, <=, =, >, !, &&, ||, in (not) null, (not) like, (not) in, (not) between and, is (not), and, or, not, xor is/is not 加上ture/false/unknown,检验某个值的真假 <=>与<>功能相同,<=>可用于null比较

排序子句: 升序:ASC,降序:DESC

去重子句: select distinct salary

Limit子句:可以被用于强制 SELECT 语句返回指定的记录数。Limit接受一个或两个数字参数。参数必须是一个整数常量。如果给定两个参数,第一个参数指定第一个返回记录行的偏移量,第二个参数指定返回记录行的最大数目。

//初始记录行的偏移量是 0(而不是 1):

mysql> SELECT * FROM table LIMIT 5,10;  #检索记录行6-15

//为了检索从某一个偏移量到记录集的结束所有的记录行,可以指定第二个参数为 -1:

mysql> SELECT * FROM table LIMIT 95,-1;  #检索记录行 96-last

//如果只给定一个参数,它表示返回最大的记录行数目。换句话说,LIMIT n 等价于 LIMIT 0,n:

mysql> SELECT * FROM table LIMIT 5;  #检索前 5 个记录行

//offset子句,跳过前多少条,在选择第几条:

select * from employees order by hire_date desc limit 1 offset 2; #跳过前两条检索,实际检索第三个个记录行

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值