zoukankan      html  css  js  c++  java
  • mysql系列3 SQL语法基础

    1.创建数据库(语法)

      

      

    2.创建(数据库)表(语法)

      

     

        复制新的空表举个例子:

          

    mysql> use course;
    Reading table information for completion of table and column names
    You can turn off this feature to get a quicker startup with -A

    Database changed
    mysql> show tables;
    +------------------+
    | Tables_in_course |
    +------------------+
    | students |
    +------------------+
    1 row in set (0.00 sec)

    mysql> desc students;
    +--------+-------------+------+-----+---------+-------+
    | Field | Type | Null | Key | Default | Extra |
    +--------+-------------+------+-----+---------+-------+
    | id | int(11) | YES | | NULL | |
    | name | varchar(16) | YES | | NULL | |
    | gender | int(11) | YES | | NULL | |
    +--------+-------------+------+-----+---------+-------+
    3 rows in set (0.01 sec)

    mysql> insert into students values('1','lili','01'),('2','hanmeimei','02');
    Query OK, 2 rows affected (0.04 sec)
    Records: 2 Duplicates: 0 Warnings: 0

    mysql> select * from students;
    +------+-----------+--------+
    | id | name | gender |
    +------+-----------+--------+
    | 1 | lili | 1 |
    | 2 | hanmeimei | 2 |
    +------+-----------+--------+
    2 rows in set (0.00 sec)

    mysql> create table students_copy like students;
    Query OK, 0 rows affected (0.13 sec)

    mysql> show tables;
    +------------------+
    | Tables_in_course |
    +------------------+
    | students |
    | students_copy |
    +------------------+
    2 rows in set (0.01 sec)

    mysql> desc students_copy;
    +--------+-------------+------+-----+---------+-------+
    | Field | Type | Null | Key | Default | Extra |
    +--------+-------------+------+-----+---------+-------+
    | id | int(11) | YES | | NULL | |
    | name | varchar(16) | YES | | NULL | |
    | gender | int(11) | YES | | NULL | |
    +--------+-------------+------+-----+---------+-------+
    3 rows in set (0.00 sec)

    mysql> desc students;
    +--------+-------------+------+-----+---------+-------+
    | Field | Type | Null | Key | Default | Extra |
    +--------+-------------+------+-----+---------+-------+
    | id | int(11) | YES | | NULL | |
    | name | varchar(16) | YES | | NULL | |
    | gender | int(11) | YES | | NULL | |
    +--------+-------------+------+-----+---------+-------+
    3 rows in set (0.00 sec)

     

     

     

       创建索引例子:    

    mysql> show tables
    -> ;
    +------------------+
    | Tables_in_course |
    +------------------+
    | students |
    | students_copy |
    | students_copy01 |
    | students_copy02 |
    | students_copy03 |
    +------------------+
    5 rows in set (0.00 sec)

    mysql> select * from students;
    +----+-----------+--------+
    | id | name | gender |
    +----+-----------+--------+
    | 1 | lili | 1 |
    | 2 | hanmeimei | 2 |
    +----+-----------+--------+
    2 rows in set (0.00 sec)

    mysql> create index index01 on students(name);
    Query OK, 0 rows affected (0.55 sec)
    Records: 0 Duplicates: 0 Warnings: 0

     

     

     

     

     

        

  • 相关阅读:
    hdu 3415 Max Sum of MaxKsubsequence
    poj 2243 Knight Moves
    【LCD手册】飞凌3.5/4.3/5.6/7/8 寸LCD手册大全下载
    【转载zq2002好文章】Windows CE 休眠唤醒全面解析(基于2440平台)(1)(2)(3)
    【转载】如果做到窗口自动适应不同尺寸屏幕的尺寸?
    【转载】wince6.0+s3c6410摄像头驱动修改
    推荐一个比较活跃的ARM/WinCE/LinuxQQ群
    【转载】微软的USB摄像头驱动,
    【收集】ARM+WinCE QQ 群
    【转载】S3C6410移植日记系列
  • 原文地址:https://www.cnblogs.com/renyongbin/p/11925822.html
Copyright © 2011-2022 走看看