第一篇:数据库基本管理(mysql)
?
?
一,Mysql 基本操作
1,庫的管理
看現有的庫
新建庫t1
mysql> create database t1;
刪除庫t1
mysql> drop database t1;
2,表的管理
mysql> use mysql;? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?//切換到t1庫
mysql> show tables;? ? ? ? ? ? ? ? ? ? ? ? ? ? //看庫里有哪些表
mysql> desc user;? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?//看user表的字段結構
>create table studb.stuinfo(name char(10),age int);? ? ? ? ? ? ? ? ?//建表
?
3,記錄的管理
?
查看所有表記錄:
>select * from studb.stuinfo;
插入表記錄:
>insert into studb.stuinfo values("bob",21),("tom",23);
修改表記錄:
>update studb.stuinfo set age=19 where name="bob";
>update studb.stuinfo set age=15;
>select?
刪表:drop table stuinfo;
刪表里的記錄
>delete from studb.stuinfo where name="tom"; ?
>delete from studb.stuinfo ;
>show tables;
刪庫:drop database studb;
?
****關系
服務器數據庫---------->庫----------->表------------------>記錄--------------------->列
4,設置表的字符集
字符集:gb2312/? ?utf8
讓支持中文:
>show create table t1;?? ??? ?//查幫助
mysql> create database 學生庫;
Query OK, 1 row affected (0.00 sec)
mysql> use 學生庫;
mysql> create table 學生表 ( 姓名 char(10),年齡 int ) DEFAULT CHARSET=utf8;
>show tables;
>insert into 學生表 values("張三豐",100);
>select * from 學生庫.學生表;
注意:修改mysql的默認字符集
#vim /etc/my/cnf
[mysql]
character_set_server=utf8
#systemctl restart mysqld
>show variables like '%character%';?? ?//確認更改結果
?
?
?
?
總結
以上是生活随笔為你收集整理的第一篇:数据库基本管理(mysql)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 第一篇:构建Mysql服务器
- 下一篇: 第一篇:Mysql数据类型