zoukankan      html  css  js  c++  java
  • MySQL 一般操作语句

    //创建数据库(PHP中MySQL语句结尾不用加;,因为PHP中MySQL语气每次只能执行一句)
    create database testdatabase;
    
    //选择数据库
    use testdatabase;
    
    //创建数据表
    create table test_table(first_name varchar(30),last_name varchar(30));

    //显示数据表机构
    descrjbe test_table
    //向数据表插入数据 insert into test_table(first_name,last_name)values('Sally','Jones');
    //这个不太好
    insert into test_table values('Sally','Jones');
    //查询数据 select * from test_table; select first_name from test_table; select first_name from test_table where first_name='Sally';
    //排序 desc(降序) asc(升序)
    select * from test_table order by age desc,score asc;
    //清空数据表数据 delete from test_table; //删除数据表一行数据 delete from test_table where first_name='Sally' or last_name='Jones'; //删除数据表 drop table test_table; //删除数据库 drop database testdatabase; //为数据表增加一列 alter table test_table add id int; //为数据表增加一列,并设置为主键(不许为空,自增,放在表最前面) alter table test_table add id int not null auto_increment first, add primary key(id); //删除数据表中的一列 alter table test_table drop column first_name;
    //修改数据表的表名
    alter table tes_table rename to test_table

    //修改数据表一列的列名和数据类型 alter table test_table change column first_name middle_name char; //修改数据表一列的列名,位置 alter table test_table modify column first_name middle_name; alter table test_table modify column first_name first; alter table test_table modify column last_name after middle_name;
  • 相关阅读:
    c++字符串排序
    JAVA实现四则运算的简单计算器
    JAVA图形小动画之简单行星运动
    JAVA多线程编程
    ege图形库之简单贪吃蛇(c++)
    ege图形库之动画排序
    mysql 性能优化方案
    MYSQL 优化常用方法
    [手把手教你] 用Swoft 搭建微服务(TCP RPC)
    php有效防止同一用户多次登录
  • 原文地址:https://www.cnblogs.com/nb08611033/p/8387573.html
Copyright © 2011-2022 走看看