当前位置: 首页 > news >正文

网上做翻译兼职网站好百度快速收录方法

网上做翻译兼职网站好,百度快速收录方法,视频教程网站模板,保定网站推广费用1.创建数据库: 使用CREATE DATABASE语句 CREATE DATABASE school;show databases; 列出MySQL数据库管理系统的数据库列表 2.切换数据库: 使用USE语句选择要操作的数据库 USE school;select database (); 当前所在库mysql> select…

1.创建数据库: 使用CREATE DATABASE语句

CREATE DATABASE school;show databases;    列出MySQL数据库管理系统的数据库列表

2.切换数据库: 使用USE语句选择要操作的数据库 

USE school;select database ();   当前所在库mysql> select version ();     查看版本号
+------------+
| version () |
+------------+
| 8.0.20     |
+------------+
1 row in set (0.00 sec)show variables like 'datadir';  在数据库中查看数据库目录存储位置mysql> show variables like 'datadir';
+---------------+--------------+
| Variable_name | Value        |
+---------------+--------------+
| datadir       | /data/mysql/ |
+---------------+--------------+
1 row in set (0.01 sec)如果使用的是InnoDB存储引擎.frm表结构文件.ibd表内数据(表数据和索引文件)一起存放在data目录下。
MySQL 8.0开始,.frm文件不再单独存在,而是被整合到了.ibd文件中。

3.创建表: 使用CREATE TABLE语句创建表 

1-create table 表名 (id int, name char(10));2-CREATE TABLE student (id INT PRIMARY KEY,name VARCHAR(10),gender VARCHAR(10),age INT
);3-create table student2 (id int primary  KEY AUTO_INCREMENT,name varchar(50) not null,gender varchar(5) not null,age int not null
);drop table  表名;  删除所在库中的数据表delete from 表名;  清除表内容不删除结构show tables;      查看所在库的表有哪些select * from student;  查看指定表

 4.查看当前表结构

DESCRIBE 表名;    查看当前表结构     
desc student2;      显示数据表的结构mysql> DESCRIBE student2;
+--------+-------------+------+-----+---------+----------------+
| Field  | Type        | Null | Key | Default | Extra          |
+--------+-------------+------+-----+---------+----------------+
| id     | int         | NO   | PRI | NULL    | auto_increment |
| name   | varchar(10) | NO   |     | NULL    |                |
| gender | varchar(10) | NO   |     | NULL    |                |
| age    | int         | NO   |     | NULL    |                |
| phone  | varchar(20) | YES  |     | 未知    |                |
+--------+-------------+------+-----+---------+----------------+
5 rows in set (0.00 sec)

5.表结构 增加删除指定列

在表中增加电话列及数据类型 默认为null
alter table student2 add column  phone varchar(20);  mysql> select * from student;
+----+------+--------+-----+-------+
| id | name | gender | age | phone |
+----+------+--------+-----+-------+
|  1 | jack | male   |  22 | NULL  |
|  2 | mak  | male   |  17 | NULL  |
|  4 | lily | male   |  18 | NULL  |
+----+------+--------+-----+-------+
3 rows in set (0.00 sec)在表中增加电话列及数据类型 列的默认值为‘未知’
ALTER TABLE student ADD COLUMN phone VARCHAR(20) DEFAULT '未知';mysql> select * from student2;
+----+------+--------+-----+--------+
| id | name | gender | age | phone  |
+----+------+--------+-----+--------+
|  1 | tom  | male   |  21 | 未知   |
|  2 | lily | Female |  21 | 未知   |
|  3 | lucy | Female |  17 | 未知   |
|  4 | bibo | male   |  17 | 未知   |
+----+------+--------+-----+--------+
4 rows in set (0.00 sec)alter table student2 add column  address varchar(255);  增加student2表地址列列      地址
alter table student2 drop column address;       删除student2表地址列

6.表结构 修改 

mysql> select * from student;
+----+------+--------+-----+-------+
| id | name | gender | age | phone |
+----+------+--------+-----+-------+    电话列修改为地址
|  1 | jack | male   |  22 | NULL  |
|  4 | lily | male   |  18 | NULL  |
+----+------+--------+-----+-------+
2 rows in set (0.01 sec)mysql> alter table student change phone address varchar(50);
Query OK, 0 rows affected (0.01 sec)
Records: 0  Duplicates: 0  Warnings: 0mysql> select * from student;
+----+------+--------+-----+---------+
| id | name | gender | age | address |
+----+------+--------+-----+---------+
|  1 | jack | male   |  22 | NULL    |
|  4 | lily | male   |  18 | NULL    |
+----+------+--------+-----+---------+
2 rows in set (0.00 sec)mysql> alter table student modify address char(50);   修改字段数据类型
Query OK, 2 rows affected (0.02 sec)
Records: 2  Duplicates: 0  Warnings: 0mysql> desc student;
+---------+-------------+------+-----+---------+----------------+
| Field   | Type        | Null | Key | Default | Extra          |
+---------+-------------+------+-----+---------+----------------+
| id      | int         | NO   | PRI | NULL    | auto_increment |
| name    | varchar(50) | NO   |     | NULL    |                |
| gender  | varchar(5)  | NO   |     | NULL    |                |
| age     | int         | NO   |     | NULL    |                |
| address | char(50)    | YES  |     | NULL    |                |
+---------+-------------+------+-----+---------+----------------+
5 rows in set (0.00 sec)https://www.runoob.com/mysql/mysql-data-types.html      菜鸟教程

7.修改数据表名 

rename table 表名 to 新表名;show tables;    查看修改结果

8.插入数据: 使用INSERT INTO语句向表中插入数据 

insert into 表名 set id=1, name='lee', age=21;INSERT INTO student (id, name, gender, age) VALUES (1, 'John', male, 30);INSERT INTO student (id, name, gender, age) VALUES (1, 'lily', Female, 31);update 表名 set id=8 where name='lee';    修改lee的id编号为8

9.查询数据表: 使用SELECT语句从表中检索数据

SELECT * FROM student;select id, name from student where gender ='Female';   查询所有女生的学号和姓名select id,name from student2 where age >20;     查询年龄大于20的id和姓名

10.更改数据: 使用UPDATE语句更新表中的数据 

UPDATE student SET age = 35 WHERE id = 1;     修改id为1的年龄为35

11.删除数据: 使用DELETE FROM语句从表中删除数据 

DELETE FROM student WHERE id = 1;
delete from 表名 where id=1;              删除id=1行的数据delete from student where age <18;    删除年龄小于 18 岁的学生

12. 删除表

drop table  表名;  删除所在库中的数据表delete from 表名;  清除表内容不删除结构

13.查询过滤条件: 使用WHERE子句指定查询的过滤条件 

SELECT * FROM student WHERE age > 25;      查询年龄大于25的

14.排序: 使用ORDER BY子句对查询结果进行排序 

SELECT * FROM student ORDER BY age DESC;     按年龄从大到小

15.聚合函数: 使用聚合函数如SUMAVGCOUNT等对数据进行统计 

SELECT COUNT(*) FROM student;    统计student表人数SUM() 求和
AVG() 平均值
COUNT() 统计

16.分组: 使用GROUP BY子句对数据进行分组 

SELECT department, AVG(salary) FROM employees GROUP BY department;employees   员工   表
department  部门   列
AVG()       函数计算每个部门的平均薪资
salary      工资
GROUP BY    按部门分组数据从employees表中选择department列。
对salary列使用AVG()聚合函数计算每个部门的平均薪资。
使用GROUP BY department对结果进行分组,确保每个部门只计算一次平均薪资。
执行这个查询后,您将得到一个结果集,其中包含每个部门的名称和对应的平均薪资。

17.查看表结构SQL语句 

mysql> show create table student2;
+----------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table    | Create Table                                                                                                                                                                                                                                                                                         |
+----------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| student2 | CREATE TABLE `student2` (`id` int NOT NULL AUTO_INCREMENT,`name` varchar(10) NOT NULL,`gender` varchar(10) NOT NULL,`age` int NOT NULL,`phone` varchar(20) DEFAULT '未知',PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci   |
+----------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

 练习用表

CREATE database company;mysql> CREATE TABLE company.employee(id int primary key AUTO_INCREMENT not null,name varchar(30) not null,age int,sex enum('male','female') default 'male' not null,hire_date date not null,post varchar(50) not null,job_description varchar(100),salary double(15,2) not null,office int,dep_id int);INSERT INTO company.employee(name, age, sex, hire_date, post, job_description, salary, office, dep_id) VALUES 
('jack', 31, 'male', '20180202', 'instructor', 'teach', 5000, 501, 100),
('tom', 32, 'male', '20180203', 'instructor', 'teach', 5500, 501, 100),
('robin', 33, 'male', '20180202', 'instructor', 'teach', 8000, 501, 100),
('alice', 34, 'female', '20180202', 'instructor', 'teach', 7200, 501, 100),
('wing', 35, 'male', '20180202', 'hr', 'hrcc', 600, 502, 101),
('harry', 36, 'male', '20180202', 'hr', NULL, 6000, 502, 101),
('emma', 37, 'female', '20180206', 'sale', 'salecc', 20000, 503, 102),
('christine', 38, 'female', '20180205', 'sale', 'salecc', 2200, 503, 102),
('zhuzhu', 39, 'male', '20180205', 'sale', NULL, 2200, 503, 102),
('gougou', 40, 'male', '20180205', 'sale', '', 2200, 503, 102);

查看表结构

mysql> desc employee;
+-----------------+-----------------------+------+-----+---------+----------------+
| Field           | Type                  | Null | Key | Default | Extra          |
+-----------------+-----------------------+------+-----+---------+----------------+
| id              | int                   | NO   | PRI | NULL    | auto_increment |
| name            | varchar(30)           | NO   |     | NULL    |                |
| age             | int                   | YES  |     | NULL    |                |
| sex             | enum('male','female') | NO   |     | male    |                |
| hire_date       | date                  | NO   |     | NULL    |                |
| post            | varchar(50)           | NO   |     | NULL    |                |
| job_description | varchar(100)          | YES  |     | NULL    |                |
| salary          | double(15,2)          | NO   |     | NULL    |                |
| office          | int                   | YES  |     | NULL    |                |
| dep_id          | int                   | YES  |     | NULL    |                |
+-----------------+-----------------------+------+-----+---------+----------------+
10 rows in set (0.00 sec)

查看表

mysql> mysql> select * from employee;
+----+-----------+------+--------+------------+------------+-----------------+----------+--------+--------+
| id | name      | age  | sex    | hire_date  | post       | job_description | salary   | office | dep_id |
+----+-----------+------+--------+------------+------------+-----------------+----------+--------+--------+
|  1 | jack      |   31 | male   | 2018-02-02 | instructor | teach           |  5000.00 |    501 |    100 |
|  2 | tom       |   32 | male   | 2018-02-03 | instructor | teach           |  5500.00 |    501 |    100 |
|  3 | robin     |   33 | male   | 2018-02-02 | instructor | teach           |  8000.00 |    501 |    100 |
|  4 | alice     |   34 | female | 2018-02-02 | instructor | teach           |  7200.00 |    501 |    100 |
|  5 | wing      |   35 | male   | 2018-02-02 | hr         | hrcc            |   600.00 |    502 |    101 |
|  6 | harry     |   36 | male   | 2018-02-02 | hr         | NULL            |  6000.00 |    502 |    101 |
|  7 | emma      |   37 | female | 2018-02-06 | sale       | salecc          | 20000.00 |    503 |    102 |
|  8 | christine |   38 | female | 2018-02-05 | sale       | salecc          |  2200.00 |    503 |    102 |
|  9 | zhuzhu    |   39 | male   | 2018-02-05 | sale       | NULL            |  2200.00 |    503 |    102 |
| 10 | gougou    |   40 | male   | 2018-02-05 | sale       |                 |  2200.00 |    503 |    102 |
+----+-----------+------+--------+------------+------------+-----------------+----------+--------+--------+
10 rows in set (0.00 sec)
mysql> select job_description, avg(salary) from employee group by job_description;
+-----------------+--------------+
| job_description | avg(salary)  |
+-----------------+--------------+
| teach           |  6425.000000 |
| hrcc            |   600.000000 |         不同职位的平均薪资
| NULL            |  4100.000000 |
| salecc          | 11100.000000 |
|                 |  2200.000000 |
+-----------------+--------------+
5 rows in set (0.01 sec)
mysql> select job_description, sum(age) from employee8 group by job_description;
+-----------------+----------+
| job_description | sum(age) |
+-----------------+----------+
| teach           |      130 |
| hrcc            |       35 |       不同部门人员年龄的和
| NULL            |       75 |
| salecc          |       75 |
|                 |       40 |
+-----------------+----------+
5 rows in set (0.01 sec)
mysql> select post, count(*) from employee group by post;
+------------+----------+
| post       | count(*) |
+------------+----------+
| instructor |        4 |    
| hr         |        2 |      统计员工表不同职位的人数 
| sale       |        4 |
+------------+----------+
3 rows in set (0.00 sec)

http://www.yidumall.com/news/8135.html

相关文章:

  • 欧美 电台 网站模板网页设计首页制作
  • 做响应式网站用什么框架企业网站seo方案
  • 盐城建设银行网站百度投诉电话人工客服24小时
  • 酒店自建网站的功能百度广告推广收费标准
  • 亚马逊网站首页网络营销岗位描述的内容
  • 下载建设银行官方网站抖音seo排名系统
  • 桂林北站怎么去阳朔视频号最新动作
  • 做网站跟推广哪家公司好友情链接软件
  • 跨境网站有哪些网页制作
  • avada做外贸网站云南网站推广公司
  • 重庆奉节网站建设公司推荐信息流广告优化师
  • 模糊背景网站数字营销软件
  • 族蚂建站怎么样公司营销策划方案案例
  • 衢州 做网站百度热搜榜排名今日
  • 团购网站优化佛山seo网站排名
  • 安徽工程信息网官网首页做网站怎么优化
  • 深圳品牌网站建设公司排名快速收录域名
  • 太原网站推广教程济宁百度推广电话
  • 芜湖 网站建设seo教程 百度网盘
  • 网站建设实训总结封面网站关键词优化排名怎么做
  • ps切片工具做网站深圳网络公司推广平台
  • 统一汤达人选择她做汤面活动网站优化师是一份怎样的工作
  • 互联网网站开发的未来方向优化落实防控措施
  • 一个网站如何挣钱百度搜索优化怎么做
  • 运城做网站sem网络推广公司
  • 定制网站开发冬天里的白玫瑰谷歌广告联盟
  • 网站建设 用户管理湘潭营销型网站建设
  • 衡水专业网站建设公司网络推广seo怎么弄
  • 关于服饰搭配做的比较好的网站关键词排名seo
  • 新媒体运营需要哪些技能青岛seo排名扣费