mysql数据库的操作

MySQL数据库的操作

1. 看库 : show databases;

2. 建库 : create database 数据库名

3. 查看数据库中数据表的信息

   use 数据库名; (调用哪个数据库)

   show tables;

4. 查看数据表中有哪些字段(也就是看表结构)

   describe 数据库名.表名

5. 删库: drop database 数据库名

6. 建新表 (在建表之前先调用要存放表的数据库)

 create table users (user_name char(20) not null,user_passwd char(30) default ‘’,primary key (user_name));

 解释:在调用的数据库中创建一个名为users的表,表内有两个字段,user_name 后面的20是最多20个字节(not null)不能为空,user_passwd字段最多30个字节,默认为空(‘’) ;primary key(索引关键字)user_name

字段类型: int 数字类型 , char 字符串类型, not null 不能为空, char() 指定多字节个数,primary key() 指定索引字段

 

7 . 删表: drop table 数据库名.表名

 

对数据库中的一个表进行增,,,

1 . 增也就是插入

insert into 库名.表名  (字段1,字段2) values (1’,’2’);

字段1对值1,字段2对值2

或者

insert  into  库名.表名 values(1’,’2’)有几个字段就有几个值

2.  (删的是含有谁的行)

delete  from 库名.表名  where  user_name=包含的内容

3. 

update  库名.表名  set  字段名1=1’  where 条件表达式

 

update auth.users set user_passwd=password(‘’) where user_name=’lisi’; lisi的密码清空

4.  select 也就是读

select 字段名 from 库名.表名;

select  字段名 from 库名.表名 where 条件表达

select  * from  auth.users  where  user_name=’zhangsan’

查找含有zhangsan的行的信息

转载于:https://www.cnblogs.com/lijianjie/p/10008126.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值