//MySQL 5.1参考手册

CREATE TABLE pet (name VARCHAR(20), owner VARCHAR(20),
species VARCHAR(20), sex CHAR(1), birth DATE, death DATE); //创建表 mysql> show tables; //查看数据库中的表
+----------------+
| Tables_in_test |
+----------------+
| pet |
+----------------+
1 row in set (0.00 sec) mysql> describe pet; //查看表的结构
+---------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------+-------------+------+-----+---------+-------+
| name | varchar(20) | YES | | NULL | |
| owner | varchar(20) | YES | | NULL | |
| species | varchar(20) | YES | | NULL | |
| sex | char(1) | YES | | NULL | |
| birth | date | YES | | NULL | |
| death | date | YES | | NULL | |
+---------+-------------+------+-----+---------+-------+
6 rows in set (0.00 sec) //导入txt文件中的数据
LOAD DATA LOCAL INFILE 'E:\\pet.txt' INTO TABLE pet; //导入txt文件中的数据
load data local infile 'E:\\data.txt' into table pet; mysql> INSERT INTO pet
-> VALUES ('Puffball','Diane','hamster','f','1999-03-30',NULL); //一次导入一条数据
Query OK, 1 row affected (0.40 sec) mysql> select * from pet where name='bowser'; //查询name=XxxxX的数据
+--------+-------+---------+------+------------+------------+
| name | owner | species | sex | birth | death |
+--------+-------+---------+------+------------+------------+
| bowser | diane | dog | m | 1979-08-31 | 1995-07-29 |
+--------+-------+---------+------+------------+------------+
1 row in set (0.00 sec) mysql> select * from pet where birth>'1998-1-1'; //查询birth在1998-1-1之后的数据
+----------+-------+---------+------+------------+-------+
| name | owner | species | sex | birth | death |
+----------+-------+---------+------+------------+-------+
| chirpy | gwen | bird | f | 1998-09-11 | NULL |
| Puffball | Diane | hamster | f | 1999-03-30 | NULL |
+----------+-------+---------+------+------------+-------+
2 rows in set (0.00 sec) mysql> select * from pet where species='dog' and sex='f'; //组合条件的使用
+-------+--------+---------+------+------------+-------+
| name | owner | species | sex | birth | death |
+-------+--------+---------+------+------------+-------+
| buffy | harold | dog | f | 1989-05-13 | NULL |
+-------+--------+---------+------+------------+-------+
1 row in set (0.00 sec) mysql> select * from pet where species='dog' or species='bird'; //or操作符,满足一个条件即可
+----------+--------+---------+------+------------+------------+
| name | owner | species | sex | birth | death |
+----------+--------+---------+------+------------+------------+
| buffy | harold | dog | f | 1989-05-13 | NULL |
| fang | benny | dog | m | 1990-08-27 | NULL |
| bowser | diane | dog | m | 1979-08-31 | 1995-07-29 |
| chirpy | gwen | bird | f | 1998-09-11 | NULL |
| whistler | gwen | bird | | 1997-12-09 | NULL |
+----------+--------+---------+------+------------+------------+
5 rows in set (0.00 sec) mysql> select * from pet where (species='cat' and sex='m') //and、or混用
-> or (species='dog' and sex='f');
+-------+--------+---------+------+------------+-------+
| name | owner | species | sex | birth | death |
+-------+--------+---------+------+------------+-------+
| claws | gwen | cat | m | 1994-03-17 | NULL |
| buffy | harold | dog | f | 1989-05-13 | NULL |
+-------+--------+---------+------+------------+-------+
2 rows in set (0.00 sec) mysql> select name,birth from pet; //输出制定的字段内容
+----------+------------+
| name | birth |
+----------+------------+
| fluff | 1993-02-04 |
| claws | 1994-03-17 |
| buffy | 1989-05-13 |
| fang | 1990-08-27 |
| bowser | 1979-08-31 |
| chirpy | 1998-09-11 |
| whistler | 1997-12-09 |
| slim | 1996-04-29 |
| Puffball | 1999-03-30 |
+----------+------------+
9 rows in set (0.00 sec) mysql> select distinct owner from pet; //对输出的字段做去重处理
+--------+
| owner |
+--------+
| harold |
| gwen |
| benny |
| diane |
+--------+
4 rows in set (0.00 sec) mysql> select name,birth from pet order by birth; //对birth排序,默认升序
+----------+------------+
| name | birth |
+----------+------------+
| bowser | 1979-08-31 |
| buffy | 1989-05-13 |
| fang | 1990-08-27 |
| fluff | 1993-02-04 |
| claws | 1994-03-17 |
| slim | 1996-04-29 |
| whistler | 1997-12-09 |
| chirpy | 1998-09-11 |
| Puffball | 1999-03-30 |
+----------+------------+
9 rows in set (0.00 sec) mysql> select name,birth from pet order by birth desc; //降序排列,最小值放第一个位置
+----------+------------+
| name | birth |
+----------+------------+
| Puffball | 1999-03-30 |
| chirpy | 1998-09-11 |
| whistler | 1997-12-09 |
| slim | 1996-04-29 |
| claws | 1994-03-17 |
| fluff | 1993-02-04 |
| fang | 1990-08-27 |
| buffy | 1989-05-13 |
| bowser | 1979-08-31 |
+----------+------------+
9 rows in set (0.00 sec) mysql> select name,species,birth from pet order by species,birth desc; //对多列排序,一个升序一个降序
+----------+---------+------------+
| name | species | birth |
+----------+---------+------------+
| chirpy | bird | 1998-09-11 |
| whistler | bird | 1997-12-09 |
| claws | cat | 1994-03-17 |
| fluff | cat | 1993-02-04 |
| fang | dog | 1990-08-27 |
| buffy | dog | 1989-05-13 |
| bowser | dog | 1979-08-31 |
| Puffball | hamster | 1999-03-30 |
| slim | snake | 1996-04-29 |
+----------+---------+------------+
9 rows in set (0.00 sec) //计算年龄
mysql> select name,birth,curdate(), //当前日期
-> (year(curdate())-year(birth))-(right(curdate(),5)<right(birth,5)) //这里还是有一些不理解,后面慢慢研究
-> as age //字段重命名为age
-> from pet;
+----------+------------+------------+------+
| name | birth | curdate() | age |
+----------+------------+------------+------+
| fluff | 1993-02-04 | 2016-10-30 | 23 |
| claws | 1994-03-17 | 2016-10-30 | 22 |
| buffy | 1989-05-13 | 2016-10-30 | 27 |
| fang | 1990-08-27 | 2016-10-30 | 26 |
| bowser | 1979-08-31 | 2016-10-30 | 37 |
| chirpy | 1998-09-11 | 2016-10-30 | 18 |
| whistler | 1997-12-09 | 2016-10-30 | 18 |
| slim | 1996-04-29 | 2016-10-30 | 20 |
| Puffball | 1999-03-30 | 2016-10-30 | 17 |
+----------+------------+------------+------+
9 rows in set (0.00 sec) //针对rigth做的解释案例
mysql> select curdate(); //当前日期,格式为2016-10-30
+------------+
| curdate() |
+------------+
| 2016-10-30 |
+------------+ mysql> select right(curdate(),5); //取后边5个字符,如此可以让年龄计算更加的精确
+--------------------+
| right(curdate(),5) |
+--------------------+
| 10-30 |
+--------------------+ mysql> select name,birth,curdate(),
-> (year(curdate())-year(birth))-(right(curdate(),5)<right(birth,5))
-> as age
-> from pet
-> order by age; //按照年龄排序,age是字段的别称
+----------+------------+------------+------+
| name | birth | curdate() | age |
+----------+------------+------------+------+
| Puffball | 1999-03-30 | 2016-10-30 | 17 |
| chirpy | 1998-09-11 | 2016-10-30 | 18 |
| whistler | 1997-12-09 | 2016-10-30 | 18 |
| slim | 1996-04-29 | 2016-10-30 | 20 |
| claws | 1994-03-17 | 2016-10-30 | 22 |
| fluff | 1993-02-04 | 2016-10-30 | 23 |
| fang | 1990-08-27 | 2016-10-30 | 26 |
| buffy | 1989-05-13 | 2016-10-30 | 27 |
| bowser | 1979-08-31 | 2016-10-30 | 37 |
+----------+------------+------------+------+
9 rows in set (0.00 sec) mysql> select name,birth,death,
-> (year(death)-year(birth))-(right(death,5)< right(birth,5)) //计算已死亡年数
-> as age
-> from pet where death is not null order by age; 抓取不为空的数据
+--------+------------+------------+------+
| name | birth | death | age |
+--------+------------+------------+------+
| bowser | 1979-08-31 | 1995-07-29 | 15 |
+--------+------------+------------+------+
1 row in set (0.00 sec) mysql> select name,birth,month(birth) from pet; /出生月份
+----------+------------+--------------+
| name | birth | month(birth) |
+----------+------------+--------------+
| fluff | 1993-02-04 | 2 |
| claws | 1994-03-17 | 3 |
| buffy | 1989-05-13 | 5 |
| fang | 1990-08-27 | 8 |
| bowser | 1979-08-31 | 8 |
| chirpy | 1998-09-11 | 9 |
| whistler | 1997-12-09 | 12 |
| slim | 1996-04-29 | 4 |
| Puffball | 1999-03-30 | 3 |
+----------+------------+--------------+
9 rows in set (0.01 sec) mysql> select name,birth from pet
-> where month(birth)=month(date_add(curdate(),interval 2 month));
//在当前月份的基础上加2个月,得到月份是当前月份+2的数据
+----------+------------+
| name | birth |
+----------+------------+
| whistler | 1997-12-09 |
+----------+------------+
1 row in set (0.00 sec) “_”匹配任何单个字符,
“%”匹配任意数目字符(包括零字符) mysql> select * from pet where name like 'b%'; //查找name以字母b开头的数据
+--------+--------+---------+------+------------+------------+
| name | owner | species | sex | birth | death |
+--------+--------+---------+------+------------+------------+
| buffy | harold | dog | f | 1989-05-13 | NULL |
| bowser | diane | dog | m | 1979-08-31 | 1995-07-29 |
+--------+--------+---------+------+------------+------------+
2 rows in set (0.00 sec) mysql> select * from pet where name like '%fy'; //查找以fy结尾的数据
+-------+--------+---------+------+------------+-------+
| name | owner | species | sex | birth | death |
+-------+--------+---------+------+------------+-------+
| buffy | harold | dog | f | 1989-05-13 | NULL |
+-------+--------+---------+------+------------+-------+
1 row in set (0.02 sec) mysql> select * from pet where name like '%w%'; //查找name中包含了w字母的数据
+----------+-------+---------+------+------------+------------+
| name | owner | species | sex | birth | death |
+----------+-------+---------+------+------------+------------+
| claws | gwen | cat | m | 1994-03-17 | NULL |
| bowser | diane | dog | m | 1979-08-31 | 1995-07-29 |
| whistler | gwen | bird | | 1997-12-09 | NULL |
+----------+-------+---------+------+------------+------------+
3 rows in set (0.00 sec) mysql> select * from pet where name like '_____'; //查找name正好包含5个字母的数据
+-------+--------+---------+------+------------+-------+
| name | owner | species | sex | birth | death |
+-------+--------+---------+------+------------+-------+
| fluff | harold | cat | f | 1993-02-04 | NULL |
| claws | gwen | cat | m | 1994-03-17 | NULL |
| buffy | harold | dog | f | 1989-05-13 | NULL |
+-------+--------+---------+------+------------+-------+
3 rows in set (0.00 sec) ‘.’匹配任何单个的字符。
[...]:匹配在方括号内的任何字符。
例如,“[abc]”匹配“a”、“b”或“c”。为了命名字符的范围,使用一个“-”。
[a-z]:匹配任何字母
[0-9]:匹配任何数字
“ * ”匹配零个或多个在它前面的字符。
例如,“x*”匹配任何数量的“x”字符,“[0-9]*”匹配任何数量的数字,而“.*”匹配任何数量的任何字符。
“^”:开头
“$”:结尾 mysql> select * from pet where name regexp '^b'; //查找以模式字母b开始的数据
+--------+--------+---------+------+------------+------------+
| name | owner | species | sex | birth | death |
+--------+--------+---------+------+------------+------------+
| buffy | harold | dog | f | 1989-05-13 | NULL |
| bowser | diane | dog | m | 1979-08-31 | 1995-07-29 |
+--------+--------+---------+------+------------+------------+
2 rows in set (0.00 sec) mysql> select * from pet where name regexp 'fy$'; //查找以模式字母fy结尾的数据
+-------+--------+---------+------+------------+-------+
| name | owner | species | sex | birth | death |
+-------+--------+---------+------+------------+-------+
| buffy | harold | dog | f | 1989-05-13 | NULL |
+-------+--------+---------+------+------------+-------+
1 row in set (0.00 sec) mysql> select * from pet where name regexp 'w'; //正则查找包含字母w的数据
+----------+-------+---------+------+------------+------------+
| name | owner | species | sex | birth | death |
+----------+-------+---------+------+------------+------------+
| claws | gwen | cat | m | 1994-03-17 | NULL |
| bowser | diane | dog | m | 1979-08-31 | 1995-07-29 |
| whistler | gwen | bird | | 1997-12-09 | NULL |
+----------+-------+---------+------+------------+------------+
3 rows in set (0.00 sec) mysql> select * from pet where name regexp '^.{5}$'; //查找name正好包含5个字母的数据
//正则的方式
+-------+--------+---------+------+------------+-------+
| name | owner | species | sex | birth | death |
+-------+--------+---------+------+------------+-------+
| fluff | harold | cat | f | 1993-02-04 | NULL |
| claws | gwen | cat | m | 1994-03-17 | NULL |
| buffy | harold | dog | f | 1989-05-13 | NULL |
+-------+--------+---------+------+------------+-------+
3 rows in set (0.00 sec) mysql> select count(*) from pet; //计数行
+----------+
| count(*) |
+----------+
| 9 |
+----------+
1 row in set (0.00 sec) mysql> select owner,count(*) from pet group by owner; //分组计数
+--------+----------+
| owner | count(*) |
+--------+----------+
| benny | 2 |
| diane | 2 |
| gwen | 3 |
| harold | 2 |
+--------+----------+
4 rows in set (0.00 sec) mysql> select species,sex,count(*) from pet group by species,sex; //按照species和sex2个条件进行分组
+---------+------+----------+
| species | sex | count(*) |
+---------+------+----------+
| bird | | 1 |
| bird | f | 1 |
| cat | f | 1 |
| cat | m | 1 |
| dog | f | 1 |
| dog | m | 2 |
| hamster | f | 1 |
| snake | m | 1 |
+---------+------+----------+
8 rows in set (0.00 sec) mysql> create table event (name varchar(20),date date, //创建event表,是pet的附表
-> type varchar(15),remark varchar(255));
Query OK, 0 rows affected (0.60 sec) //event.txt文件数据:
fluffy 1995/5/15 litter 4 kittens, 3 female, 1 male
buffy 1993/6/23 litter 5 puppies, 2 female, 3 male
buffy 1994/6/19 litter 3 puppies, 3 female
chirpy 1999/3/21 vet needed beak straightened
slim 1997/8/3 vet broken rib
bowser 1991/10/12 kennel
fang 1991/10/12 kennel
fang 1998/8/28 birthday Gave him a new chew toy
claws 1998/3/17 birthday Gave him a new flea collar
whistler 1998/12/9 birthday First birthday mysql> LOAD DATA LOCAL INFILE 'E:\\event.txt' INTO TABLE event; //转载数据
Query OK, 10 rows affected (0.20 sec)
Records: 10 Deleted: 0 Skipped: 0 Warnings: 0 //
mysql> select pet.name,
-> (year(date)-year(birth))-(right(date,5)<right(birth,5)) as age,
-> remark
-> from pet,event
-> where pet.name=event.name and event.type='litter';
+-------+------+------------------------------+
| name | age | remark |
+-------+------+------------------------------+
|buffy | 4 | 5 puppies, 2 female, 3 male
| 5 | 3 puppies, 3 female
+-------+------+------------------------------+
2 rows in set (0.00 sec) mysql> select pet.name,
-> remark
-> from pet,event
-> where pet.name=event.name and event.type='litter'; //联合查找 type='litter'的数据
+-------+------------------------------+
| name | remark |
+-------+------------------------------+
|buffy | 5 puppies, 2 female, 3 male
|3 puppies, 3 female
+-------+------------------------------+
2 rows in set (0.00 sec) mysql> select database(); //查找当前所有数据库,这里特指正在使用的数据库
+------------+
| database() |
+------------+
| test |
+------------+
1 row in set (0.00 sec) mysql> show tables; //查看所有表
+----------------+
| Tables_in_test |
+----------------+
| event |
| pet |
+----------------+
2 rows in set (0.00 sec) mysql> describe pet; //查找表的结构
+---------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------+-------------+------+-----+---------+-------+
| name | varchar(20) | YES | | NULL | |
| owner | varchar(20) | YES | | NULL | |
| species | varchar(20) | YES | | NULL | |
| sex | char(1) | YES | | NULL | |
| birth | date | YES | | NULL | |
| death | date | YES | | NULL | |
+---------+-------------+------+-----+---------+-------+
6 rows in set (0.00 sec) mysql> create table shop( //创建shop数据库
-> article int(4) unsigned zerofill default '' not null, //指定数字位数,位数不足自动用0补齐
-> dealer char(20) default '' not null,
-> price double(16,2) default '0.00' not null, //price保留2个小数点,16个字节,默认值0.00
-> primary key(article,dealer));
Query OK, 0 rows affected (0.62 sec) mysql> insert into shop values //插入数据,一种新的插入数据的形式
-> (1,'a',3.45),
-> (1,'b',3.99),
-> (2,'a',10.99),
-> (3,'b',1045),
-> (3,'c',1.69),
-> (3,'d',1.25),
-> (4,'d',19.95);
Query OK, 7 rows affected (0.40 sec)
Records: 7 Duplicates: 0 Warnings: 0 mysql> select * from shop; //查看全部数据结果
+---------+--------+---------+
| article | dealer | price |
+---------+--------+---------+
| 0001 | a | 3.45 |
| 0001 | b | 3.99 |
| 0002 | a | 10.99 |
| 0003 | b | 1045.00 |
| 0003 | c | 1.69 |
| 0003 | d | 1.25 |
| 0004 | d | 19.95 |
+---------+--------+---------+
7 rows in set (0.00 sec) mysql> select max(article) as '物品号最大的商品' from shop; //max
+------------------+
| 物品号最大的商品 |
+------------------+
| 4 |
+------------------+
1 row in set (0.02 sec) mysql> select article,dealer,price //查找最贵商品的编号、销售商和价格等数据
-> from shop
-> where price=
-> (select max(price) from shop); //从子查询语句来实现
+---------+--------+---------+
| article | dealer | price |
+---------+--------+---------+
| 0003 | b | 1045.00 |
+---------+--------+---------+
1 row in set (0.00 sec) mysql> select article,dealer,price //查找最贵商品的编号、销售商和价格等数据
-> from shop //排序(降序)和limit方式综合实现
-> order by price desc
-> limit 1;
+---------+--------+---------+
| article | dealer | price |
+---------+--------+---------+
| 0003 | b | 1045.00 |
+---------+--------+---------+
1 row in set (0.00 sec) mysql> select article,max(price) as price //分组求每种商品的最大值
-> from shop
-> group by article;
+---------+---------+
| article | price |
+---------+---------+
| 0001 | 3.99 |
| 0002 | 10.99 |
| 0003 | 1045.00 |
| 0004 | 19.95 |
+---------+---------+
4 rows in set (0.35 sec) mysql> select article,dealer,price //定义要查找的字段
-> from shop s1 //数据来源
-> where price= //定义数据需要满足的条件
-> (select max(s2.price) from shop s2 where s1.article = s2.article);
+---------+--------+---------+
| article | dealer | price |
+---------+--------+---------+
| 0001 | b | 3.99 |
| 0002 | a | 10.99 |
| 0003 | b | 1045.00 |
| 0004 | d | 19.95 |
+---------+--------+---------+
4 rows in set (0.00 sec) //论坛用户访问时间数据
mysql> create table t1 (year year(4),month int(2) unsigned zerofill, //创建t1表
-> day int(2) unsigned zerofill);
Query OK, 0 rows affected (0.65 sec) mysql> insert into t1 values //插入数据
-> (2000,1,1),
-> (2000,2,20),
-> (2000,1,30),
-> (2000,2,2),
-> (2000,2,23),
-> (2000,2,23);
Query OK, 6 rows affected (0.40 sec)
Records: 6 Duplicates: 0 Warnings: 0 ysql> select year,month,bit_count(bit_or(1<<day)) as days //查找同年同月访问量
-> from t1
-> group by year,month;
+------+-------+------+
| year | month | days |
+------+-------+------+
| 2000 | 01 | 2 |
| 2000 | 02 | 3 | //本来是4次,为什么是3次呢,做了去重处理
+------+-------+------+
2 rows in set (0.36 sec) mysql> create table animals( //通过AUTO_INCREMENT属性为新的行产生唯一的标识
-> id mediumint not null auto_increment,
-> name char(20) not null,
-> primary key(id)
-> );
Query OK, 0 rows affected (0.26 sec) mysql> insert into animals (name) values
-> ('dog'),
-> ('cat'),
-> ('penguin'),
-> ('lax'),
-> ('whale'),
-> ('ostrich'); mysql> select * from animals; //通过查看结果可以看出表对name自动加了编号
+----+---------+
| id | name |
+----+---------+
| 1 | dog |
| 2 | cat |
| 3 | penguin |
| 4 | lax |
| 5 | whale |
| 6 | ostrich |
+----+---------+
6 rows in set (0.00 sec) mysql> alter table animals auto_increment=100; //定义数据的编号从100开始编号
Query OK, 0 rows affected (0.37 sec)
Records: 0 Duplicates: 0 Warnings: 0 mysql> insert into animals (name) values //插入一条新的数据
-> ('cat1');
Query OK, 1 row affected (0.40 sec) mysql> select * from animals; //查看发现最新插入的数据编号为100,而不是编号7
+-----+---------+
| id | name |
+-----+---------+
| 1 | dog |
| 2 | cat |
| 3 | penguin |
| 4 | lax |
| 5 | whale |
| 6 | ostrich |
| 100 | cat1 |
+-----+---------+
7 rows in set (0.00 sec)

【收藏】常用SQL语句的更多相关文章

  1. Mysql 常用 SQL 语句集锦

    Mysql 常用 SQL 语句集锦 基础篇 //查询时间,友好提示 $sql = "select date_format(create_time, '%Y-%m-%d') as day fr ...

  2. Mysql 常用 SQL 语句集锦 转载(https://gold.xitu.io/post/584e7b298d6d81005456eb53)

    Mysql 常用 SQL 语句集锦 基础篇 //查询时间,友好提示 $sql = "select date_format(create_time, '%Y-%m-%d') as day fr ...

  3. 50个常用SQL语句

    50个常用SQL语句 Student(S#,Sname,Sage,Ssex) 学生表  S#学号,主键 Course(C#,Cname,T#) 课程表          C#课程号,主键 SC(S#, ...

  4. oracle sqlplus及常用sql语句

    常用sql语句 有需求才有动力 http://blog.csdn.net/yitian20000/article/details/6256716 常用sql语句 创建表空间:create tables ...

  5. oracle常用SQL语句(汇总版)

    Oracle数据库常用sql语句 ORACLE 常用的SQL语法和数据对象一.数据控制语句 (DML) 部分 1.INSERT (往数据表里插入记录的语句) INSERT INTO 表名(字段名1, ...

  6. 常用SQL语句(增删查改、合并统计、模糊搜索)

    转自:http://www.cnblogs.com/ljianhui/archive/2012/08/13/2695906.html 常用SQL语句 首行当然是最基本的增删查改啦,其中最重要的是查. ...

  7. oracle 常用sql语句

    oracle 常用sql语句 1.查看表空间的名称及大小 select t.tablespace_name, round(sum(bytes/(1024*1024)),0) ts_sizefrom d ...

  8. Sqlite常用sql语句

    sqlite常用sql语句 --返回UTC时间 select CURRENT_TIMESTAMP; --返回本地时间 select datetime(CURRENT_TIMESTAMP,'localt ...

  9. 常用SQL语句集合

    一.数据定义 1.创建新数据库:CREATE DATABASE database_name2.创建新表:CREATE TABLE table_name (column_name datatype,co ...

  10. 常用sql语句整理:mysql

    ## 常用sql语句整理:mysql1. 增- 增加一张表```CREATE TABLE `table_name`(  ...  )ENGINE=InnoDB DEFAULT CHARSET=utf8 ...

随机推荐

  1. 多目标进化算法(MOEA)概述

    Weighted Sum Approach 该方法给出的表达式为: 首先,λ被称之为权重向量,观察和式,这完全就是m维向量的点乘公式嘛.具体的说,在目标空间中,把算法求出的一个目标点和原点相连构造成一 ...

  2. C++11 std::shared_ptr总结与使用

    最近看代码,智能指针用的比较多,自己平时用的少,周末自己总结总结.方便后续使用. std::shared_ptr大概总结有以下几点: (1) 智能指针主要的用途就是方便资源的管理,自动释放没有指针引用 ...

  3. Asp.net web Control Enable 属性设置

    最近手上有一个很简单的一个小项目,需要查看编辑的历史记录,先前设计的时候把数据都save 到DB了,现在时间紧迫 就不在画新的UI,而是采用以前的edit页面 来显示数据,这里就需要把页面上所有的co ...

  4. Pascal's Triangle leetcode java(杨辉三角)

    题目: Given numRows, generate the first numRows of Pascal's triangle. For example, given numRows = 5, ...

  5. Combination Sum II leetcode java

    题目: Given a collection of candidate numbers (C) and a target number (T), find all unique combination ...

  6. Spring boot Unable to start embedded Tomcat报错 java.lang.NoSuchMethodError: javax.servlet.ServletContext.getVirtualServerName()

    Spring boot Unable to start embedded Tomcat 报错 java.lang.NoSuchMethodError: javax.servlet.ServletCon ...

  7. 设置虚拟机IP

    重启虚拟机 重启后,查看虚拟机IP ip a 虚拟机已有自己的IP 输入虚拟机用户

  8. 让App中增加LruCache缓存,轻松解决图片过多造成的OOM

    上次有过电话面试中问到Android中的缓存策略,当时模糊不清的回答,如今好好理一下吧. Android中普通情况下採取的缓存策略是使用二级缓存.即内存缓存+硬盘缓存->LruCache+Dis ...

  9. tensoflow数据读取

    数据读取 TensorFlow程序读取数据一共有3种方法: 供给数据(Feeding): 在TensorFlow程序运行的每一步, 让Python代码来供给数据. 从文件读取数据: 在TensorFl ...

  10. centos配置ssh免密码登录

    master.slave1两台机器实现ssh免密码登录,user:hadoop,passwd:123456 1.设置master: vi /etc/sysconfig/network hostname ...