Home > Database > Mysql Tutorial > mySql study notes: easier than writing sql server

mySql study notes: easier than writing sql server

黄舟
Release: 2017-02-15 11:05:12
Original
1057 people have browsed it

在学mySql。总的感觉,mySql与Sql Server差不多,语法都很象,但mySql也许是吸取了SQL SERVER的一些经验,SQL语句书写起来更加简单。

比如说,设置主键、索引,SQL SERVER里的语句我是记不住的,但mysql却很简便:



CREATE table t(
id int not null
,name varchar(50) null
,primary key(id)
,index ix_name(name));
Copy after login

又如:


use test;

drop table if exists t3;
CREATE TABLE t3 (
  id INT NOT NULL,
  NAME CHAR(30) NOT NULL,
  age INT NOT NULL,
  info VARCHAR (255),
  INDEX MultiIdx(id, NAME, age)
);


INSERT INTO t3(id ,NAME,age,info) VALUES(1,'小明',12,'nihao'),(2,'小芳',16,'nihao');

explain select * from t3 where name='小芳';
Copy after login


如果存在某表,先删再建之;

显示执行情况,看看复合索引是否被用,太简便了。


mysql 的查询还支持正则表达式


另外,mysql的表支持两种类型:innoDB 和 myISAM。后者不支持事务,但速度更快,很适合用在只读。

以上就是mySql学习笔记:比sql server书写要简单的内容,更多相关内容请关注PHP中文网(www.php.cn)!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template