zoukankan      html  css  js  c++  java
  • 数据库的一些知识点复习

    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;

  • 相关阅读:
    pyc文件是什么【转载】
    Linux下的python等操作【转载】
    P1012 拼数 字符串
    P1309 瑞士轮 排序选择 时间限制 归并排序
    商业竞争 三分+背包
    老虎ji 剪枝模拟
    交通灯 并查集
    三色抽卡游戏 博弈论nim
    质数串 乱搞
    自动驾驶系统 bfs
  • 原文地址:https://www.cnblogs.com/syd192/p/4737888.html
Copyright © 2011-2022 走看看