zoukankan      html  css  js  c++  java
  • 【Python】数据库练习-1

    三十四 数据库

    1、     查看数据库命令

     

    2、     使用某个数据库

     

    3、     查看当前在哪个库

     

    4、     查看当前数据库中有哪些表

     

    5、     查询表中数据

     

    6、     建库:create database testbase;

    7、     建表:create table user(id int not null);

     

     

    创建表,名字为user_wangjing,字段为 id,date1,date2等

     

     

     

    新建表名,括号里意思是int 11位,不能为空

     

    8、     插入数据:insert into user values(1);

     

    9、     查看表的信息:

     

    10、    删除表

     

    11、    删除库:drop database testbase;

    12、    新建用户:

    create user 'student11'@'%' identified by "gloryroad";

    FLUSH PRIVILEGES;

     

    %表示所有IP都可登录,'student11'@'10.60.89.%'表示只有这个字段的IP可以登录

    13、    修改密码:

    UPDATE USER SET PASSWORD=PASSWORD('12345622xw1') WHERE USER='gg1';

    FLUSH PRIVILEGES;

    14、    创建用户和修改用户的权限

    grant all privileges on test.user to student@"%" identified by "gloryroad" ;  #让用户拥有操作任意数据库的权限

    flush privileges;

    15、    建表,插入值

     

    ENGINE=InnoDB存储数据库采用innoDB引擎,如果你想使用外键,事务等功能,就需要innodb引擎

    16、    查看表的字段和属性: show columns from book_wangjing;

     

    17、    查看索引:SHOW INDEX FROM book_wangjing;

     

    18、    查看2条数据,从头开始前两条不看,打印接着后面的

     

    19、    查看2条之后的3条

     

    20、    查询表数据 and or:

     

    21、    给表中的字段起一个别名

     

    22、    表中字段的排序

     

    select * from book where book_author like '%老师';

    计算表中数据条数:

     

    计算平均值:

     

  • 相关阅读:
    Ognl表达式基本原理和使用方法
    Struts的拦截器
    Struts框架的核心业务
    Struts2框架基础
    Struts的文件上传下载
    .JavaWeb文件上传和FileUpload组件使用
    mysql数据库连接与锁查询
    关于MyBatis的@Mapper和@MapperScan注解的一点思考
    Hystrix报错java.util.concurrent.TimeoutException: null
    The Hystrix timeout of 2000ms for the command xxx is set lower than the combination of the Ribbon read and connect timeout, 4000ms.
  • 原文地址:https://www.cnblogs.com/jingsheng99/p/8951773.html
Copyright © 2011-2022 走看看