数据库的一些知识点复习

1.     一些知识点

  在计算机的系统属性中的环境变量PATH中可以加入mysql.exe的路径(D:\program files\wamp\bin\mysql\mysql5.5.20\bin),使得在任意目录下都可以使用mysql。举例来说:在cmd中输入mysql系统可以识别;

数据库由许多表组成,可以使用键作为表格之间的引用。

2.     一些命令及其使用

a)         创建数据库:create database suyd;

b)        查看系统中存在的数据库:show databases;

c)         切换数据库,默认当前操作在这个库中:use suyd;

d)        查看数据库suyd中存在的表:show tables;

e)         创建表:create table users(id int not null auto_increment primary key, username char(30) not null default '', password varchar(32) not null default '', age int not null default 0, sex char(4) not null default '', email varchar(80) not null default '');(引号存在点问题)''

f)         查看创建的表:show tables;

g)        查看表users的具体结构:desc users;

h)        查看创建表users的语句:show create table users;

i)          对表的操作

    插入:insert into users(id, username, password, age, sex, email) values(‘1’, ‘suyd’, ‘123456’, ‘22’, ‘girl’, ‘847909475@qq.com’);

           查询表users的情况:select * from users; 

    修改:update users set username = ‘su’ where id = 2;

    同时修改多个值:update users set age = 17, sex = ‘girl’;

    同时修改某个人的多个值:update users set age = 20, sex = ‘girl’ where id = 1;

     删除:delete from users where id = 1;

     查询

     查询表的所有情况:select * from users;

     查询表中某项的情况:select id, username from users;

    按照某种要求查询表中某项的情况:

       select id, username, age+10 as age10 from users;

           select id, username, age from users where age > 10;

j)           删除整个表或库:

     drop table users;

     drop database suyd;

转载于:https://www.cnblogs.com/syd192/p/4737888.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值