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的行的信息

  • 相关阅读:
    集合及特殊集合arrayList
    二维数组、多维数组
    一维数组

    for循坏的穷举与迭代,while、do while循环
    1.兔子生兔子问题2.打印菱形3.求100以内质数的和
    for循环嵌套
    复习题
    循环语句
    分支语句
  • 原文地址:https://www.cnblogs.com/lijianjie/p/10008126.html
Copyright © 2011-2022 走看看