• 数据库的一些知识点复习


    1.     一些知识点

      在计算机的系统属性中的环境变量PATH中可以加入mysql.exe的路径(D:program fileswampinmysqlmysql5.5.20in),使得在任意目录下都可以使用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;

  • 相关阅读:
    求两个数的最大公约数--简单
    输入7个人的成绩,找出大于平均成绩的值--简单
    回文--简单
    约瑟夫环--中等难度
    数组中查找最大数和次大数--简单
    Docker在云环境中的应用实践初探:优势、局限性与效能评测
    基于mongoDB的capped collection的性能优化
    微软开放技术(中国)携 CKAN 和 OData 技术引入基于 Azure 的开放数据平台
    ThreadPoolExecutor原理及使用
    通过 Azure Media Encoder 降低编码成本
  • 原文地址:https://www.cnblogs.com/syd192/p/4737888.html
Copyright © 2020-2023  润新知