网创优客建站品牌官网
为成都网站建设公司企业提供高品质网站建设
热线:028-86922220
成都专业网站建设公司

定制建站费用3500元

符合中小企业对网站设计、功能常规化式的企业展示型网站建设

成都品牌网站建设

品牌网站建设费用6000元

本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...

成都商城网站建设

商城网站建设费用8000元

商城网站建设因基本功能的需求不同费用上面也有很大的差别...

成都微信网站建设

手机微信网站建站3000元

手机微信网站开发、微信官网、微信商城网站...

建站知识

当前位置:首页 > 建站知识

mysql举例分析

下文内容主要给大家带来MySQL举例分析,这里所讲到的知识,与书籍略有不同,都是创新互联专业技术人员在与用户接触过程中,总结出来的,具有一定的经验分享价值,希望给广大读者带来帮助。

成都创新互联公司主营旬阳网站建设的网络公司,主营网站建设方案,成都APP应用开发,旬阳h5重庆小程序开发搭建,旬阳网站营销推广欢迎旬阳等地区企业咨询

mysql安装不介绍,mysql -uroot -p
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| test               |
+--------------------+
4 rows in set (0.02 sec)
创建表
mysql> create database publications;
Query OK, 1 row affected (0.00 sec)
查看表并使用
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| publications       |
| test               |
+--------------------+
5 rows in set (0.00 sec)

mysql> use publications;
Database changed
创建数据库管理用户
mysql> *grant all on publications. to 'huang'@'localhost' identified by "123456";
Query OK, 0 rows affected (0.00 sec)
更新权限
mysql>
flush privileges;
Query OK, 0 rows affected (0.00 sec)
创建表 查看表

mysql>create table classics(author varchar(128), title varchar(128), type varchar(16), year char(4));**
Query OK, 0 rows affected (0.01 sec)

mysql> desc classics;
+--------+--------------+------+-----+---------+-------+
| Field  | Type         | Null | Key | Default | Extra |
+--------+--------------+------+-----+---------+-------+
| author | varchar(128) | YES  |     | NULL    |       |
| title  | varchar(128) | YES  |     | NULL    |       |
| type   | varchar(16)  | YES  |     | NULL    |       |
| year   | char(4)      | YES  |     | NULL    |       |
+--------+--------------+------+-----+---------+-------+
4 rows in set (0.00 sec)
删除表
mysql> drop table classics;
Query OK, 0 rows affected (0.00 sec)

再次创建表,增加id选项
mysql> create table classics(author varchar(128), title varchar(128), type varchar(16), year char(4),id INT unsigned not null auto_increment key)ENGINE MyISAM;
Query OK, 0 rows affected (0.01 sec)
删除id选项
mysql> alter table classics drop id;
Query OK, 0 rows affected (0.00 sec)
Records: 0  Duplicates: 0  Warnings: 0

表中插入数据
mysql> insert into classics(author,title,type,year)
-> values("mark twain","muguangzhicheng",'fiction',"1876");

Query OK, 1 row affected (0.00 sec)

mysql> insert into classics(author,title,type,year) values("frank hello","xianglongshibazhang",'fiction',"1856");
Query OK, 1 row affected (0.00 sec)

mysql> insert into classics(author,title,type,year) values("world go","shgendiaoxialv",'play',"1841");
Query OK, 1 row affected (0.00 sec)

mysql> insert into classics(author,title,type,year) values("nale","xiakexing",'play',"1541");
Query OK, 1 row affected (0.00 sec)

mysql> select * from classics;
+-------------+---------------------+---------+------+
| author      | title               | type    | year |
+-------------+---------------------+---------+------+
| mark twain  | muguangzhicheng     | fiction | 1876 |
| frank hello | xianglongshibazhang | fiction | 1856 |
| world go    | shgendiaoxialv      | play    | 1841 |
| nale        | xiakexing           | play    | 1541 |
+-------------+---------------------+---------+------+
4 rows in set (0.00 sec)

更改表名称
mysql> alter table classics rename pre1900;
Query OK, 0 rows affected (0.00 sec)

mysql> show tables;
+------------------------+
| Tables_in_publications |
+------------------------+
| pre1900                |
+------------------------+
1 row in set (0.00 sec)

对于以上关于mysql举例分析,如果大家还有更多需要了解的可以持续关注我们创新互联的行业推新,如需获取专业解答,可在官网联系售前售后的,希望该文章可给大家带来一定的知识更新。



新闻名称:mysql举例分析
文章源于:http://bjjierui.cn/article/isgiph.html

其他资讯