当前位置:网站首页>学习Mysql基础第一天
学习Mysql基础第一天
2022-06-13 06:45:00 【追光459】
安装成功mysql之后,如何启动和停止mysql
一:打开window运行窗口,输入services.msc命令进入windows的系统找到Mysql的(Windows Service Name)(系统服务名称)进行启动或者关闭操作。
二:直接在命令行中输入net start mysql(Windows Service Name)/net stop mysql(Windows Service Name)
mysql当中的数据模型
关系型数据库(ROBMS)
*****************************************************
操作数据库的工具,命令行和navicat(navicat更直观也更美观)
可视化该工具navicat的使用:首先与数据库建立连接。
设置一下信息
连接成功过后,打开navicat看左下角:
数据库的逻辑关系:
存储数据的最小单元就是字段。
存储记录的最小单元就是元组。
存储数据的步骤:
创建数据库--创建数据表(声明字段)--添加数据
通过sql指令去操作数据库。
sql语言的分类:
基本语法:
1:sql语句不区分大小写
2:每条sql语句都以英文分号结束。
3:sql关键字之间以空格分隔
DDL语句:
1:DDL之数据库操作
使用DDL语句可以创建,查询,修改,删除数据库。
创建数据库:creat database +(dbname名字选填);
但是这个数据库已经存在的话,语句就会出错。这个时候,creat database if not exists(dbname名字选填);这样即使已经有数据库存在了,也不会报错,即如果存在就不创建,不存在就创建。
创建数据库时指定数据库中的字符集:utf-8和gbk都是支持中文的。
查询数据库:show databases;
修改数据库(主要指修改数据库的字符集):
关键词alter
character set(字符集设置)
删除数据库:
会删除当前数据库中所有的数据表以及数据表中的数据。
关键词:drop
数据库里面数据表,数据表里面有数据。
如果要在数据库中创建数据表,得先选择在哪个数据库中建表:
2:DDL之数据表操作
建表:
二维表格,行和列
creat table students(name1 此列容纳的类型 非空约束 唯一约束(除了名字以外其他看情况填写),name2(与name1同),name3(与name1同),name4(与name1同),name5(与name1同),name6(与name1同)) 六列就点五个逗号分隔开。
简易版:
creat table students(,,,,,);
char是固定长度的字符串,char(8)此列长度全是8或者全是7~1.
varchar是可变长度字符串,varchar(20)此列最长是10个汉字,或者十个字符,因为一个汉字占两个字符。
查询数据表:
show tables;
想要仔细查询数据表的结构的话:desc+数据表的名字;
删除数据表:
drop table 表名;
防止这张表不存在:
drop table if exists 表名;
修改数据表:主要分为修改表名,数据表的字符集,添加列(字段),修改列(字段)的列表和类型,只修改列(字段)类型,删除列(字段)。columnName是列名,change是列名和类型都改变,modify是只改变类型不改变列名。
边栏推荐
- As the new trend of blind box e-commerce, how can the platform use blind box play to drain at low cost?
- 16、 IO stream (II)
- Notepad++ settings delete current line shortcut
- Introduction to applet layout
- 上位机开发(固件下载软件之编码调试)
- JetPack - - - Navigation
- 【云原生 | Kubernetes篇】Kubernetes 配置
- JNI exception handling
- In kotlin?,!,?:,:, - & gt;、== Brief description of symbols
- 105. constructing binary trees from preorder and inorder traversal sequences
猜你喜欢
Kotlin collaboration -- context and exception handling
The new retail market has set off blind box e-commerce. Can the new blind box marketing model bring dividends to businesses?
JS case Xiaomi second kill countdown New Year Countdown
How to quickly support the team leader to attract new fission users in the business marketing mode of group rebate?
The new business outlet of beautiful Tiantian second mode will be popular in the Internet e-commerce market
Chain 2+1 reward, what kind of mode is beautiful everyday seconds?
How to use Wangyou DFM software for cold plate analysis
【云原生 | Kubernetes篇】Kubernetes 配置
Jinglianwen Technology: current situation and solutions of data acquisition and labeling industry
An article allows you to quickly understand the fission growth password of social e-commerce user marketing and avoid stepping on the pit
随机推荐
测试开发程序员,你还在迷茫吗?不能把自己定义为码农......
景联文科技提供语音数据采集标注服务
Outil de formatage du temps - mode. JS (affichage en temps réel du temps Web)
package-lock. json
【Kernel】驱动编译的两种方式:编译成模块、编译进内核(使用杂项设备驱动模板)
Soup side (8)
Why does TCP establish three handshakes and four waves
景联文科技:数据标注行业现状及解决方案
15、 IO stream (I)
Socket programming server and client (multiple clients can connect to the same port of a server at the same time)
Detailed explanation of scrcpy client code walk through H264 raw stream decoding process
机器学习笔记 - 监督学习备忘清单
Pngquant batch bat and parameter description
JetPack - - -WorkManger
Cocos released the oppo game prompt "subcontracting failed"
New Taishan crowdfunding business diversion fission growth model in 2022
Kotlin collaboration channel
Kotlin collaboration -- context and exception handling
Analyzing server problems using jvisualvm
Base64 principle