• MySQL(二)任务


    1. mysql的安装

    主要的工作平台是CentOS,所以此次学习仅在CentOS7上进行。

    之前用的多是mariadb,这个mysql分支与mysql有很高的相似度。此次学习也用mariadb

    安装步骤:

    #wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
    #rpm -ivh mysql-community-release-el7-5.noarch.rpm
    #yum update
    #yum install mysql-server
    #设置权限
    #chown mysql:mysql -R /var/lib/mysql
    #初始化
    #mysqld --initialize

    #mariadb的安装与初始化
    yum install mariadb-server mariadb
    systemctl start mariadb
    systemctl enable mariadb
    mysql_secure_installtion

    #检查配置
    mysqladmin --version

    mysql -uroot -p****

    项目一:创建表

    create database example;
    CREATE TABLE email(ID INT NOT NULL PRIMARY KEY, Email VARCHAR(255) NOT NULL);
    insert into email values('1', 'a@b.com');
    insert into email values('2', 'a@b.com');
    insert into email values('3', 'a@b.com');

     查找表中重复的内容

    select email from email having count(*) > 1;

    项目二:

    create table world (
        -> name varchar(50) not NULL,
        -> continent varchar(50) not NULL,
        -> area int not NULL,
        -> population int not NULL,
        -> gdp int not NULL);
    insert into world values('Afghanistan','Asia',652230,25500100,20343000);
    insert into world values('Albania','Europe',28748,2831741,12960000);
    insert into world values('Algeria','Africa',2381741,37100000,188681000);
    insert into world values('Andorra','Europe',468,78115,3712000);
    insert into world VALUES('Angola','Africa',1246700,20609294,100990000);

    select name,population,area from world where area > 3000000 or population > 25000000 and gdp > 20000000;

  • 相关阅读:
    Java面试题2(转)
    Java面试题1(转)
    RabbitMq、ActiveMq、ZeroMq、kafka之间的比较,资料汇总
    Java List与数组之间的转换
    JAVA面试题(3)
    JAVA面试题(2)
    JAVA面试题(1)
    SpringMVC 后台怎么获取前台jsp页面中file中的文件
    QMessageBox中按钮的汉化
    关于字符串的一些重要方法
  • 原文地址:https://www.cnblogs.com/marathoner/p/10643547.html
Copyright © 2020-2023  润新知