zoukankan      html  css  js  c++  java
  • mysql数据库的操作

    MySQL数据库的操作

    1. 看库 : show databases;

    2. 建库 : create database 数据库名

    3. 查看数据库中数据表的信息

       use 数据库名; (调用哪个数据库)

       show tables;

    4. 查看数据表中有哪些字段(也就是看表结构)

       describe 数据库名.表名

    5. 删库: drop database 数据库名

    6. 建新表 (在建表之前先调用要存放表的数据库)

     create table users (user_name char(20) not null,user_passwd char(30) default ‘’,primary key (user_name));

     解释:在调用的数据库中创建一个名为users的表,表内有两个字段,user_name 后面的20是最多20个字节(not null)不能为空,user_passwd字段最多30个字节,默认为空(‘’) ;primary key(索引关键字)user_name

    字段类型: int 数字类型 , char 字符串类型, not null 不能为空, char() 指定多字节个数,primary key() 指定索引字段

    7 . 删表: drop table 数据库名.表名

    对数据库中的一个表进行增,,,

    1 . 增也就是插入

    insert into 库名.表名  (字段1,字段2) values (1’,’2’);

    字段1对值1,字段2对值2

    或者

    insert  into  库名.表名 values(1’,’2’)有几个字段就有几个值

    2.  (删的是含有谁的行)

    delete  from 库名.表名  where  user_name=包含的内容

    3. 

    update  库名.表名  set  字段名1=1’  where 条件表达式

    update auth.users set user_passwd=password(‘’) where user_name=’lisi’; lisi的密码清空

    4.  select 也就是读

    select 字段名 from 库名.表名;

    select  字段名 from 库名.表名 where 条件表达

    select  * from  auth.users  where  user_name=’zhangsan’

    查找含有zhangsan的行的信息

  • 相关阅读:
    HDU 5154 Harry and Magical Computer bfs
    opencv第一课 打开一个图片
    Codeforces Round #131 (Div. 1) A
    Topcoder SRM 643 Div1 250<peter_pan>
    bestcoder#23 1002 Sequence II 树状数组+DP
    bestcoder#23 1001 Sequence
    Oil Deposits 搜索 bfs 强联通
    迷宫问题 模拟队列 广度优先搜索
    Codeforces Round #283 (Div. 2) C. Removing Columns 暴力
    Codeforces Round #283 (Div. 2) B. Secret Combination 暴力水题
  • 原文地址:https://www.cnblogs.com/lijianjie/p/10008126.html
Copyright © 2011-2022 走看看