zoukankan      html  css  js  c++  java
  • 对数据库的简单操作

                                                     对数据库的简单操作
    
    数据库基础值知识:关系数据库(磁盘)和非关系型数据库(内存)
    
               -->行 (记录)
    数据库-->表            -->数据
               -->列(字段)
    
    1.对数据库操作:
      增加数据库:creat database  数据库名;
      删除数据库:drop  database  数据库名;
      查看数据库:show  databases;
      
    2.对表的操作:
    
      增加:
      .创建表:create table 表名(字段 类型 not null primary key,字段 类型....)
    
       删除:
       删除表:drop table 表名;
               删除多个:drop table 表1,23....
    
       修改:
      .修改表本身:rename 旧表名 to 新表名;
      .修改表选项:alter table 表名 表选项 [=](可有可无) 值;
                   eg.alter table student charset=GBK;
    
      查看:
      .查看所有表:show tables;
      .查看部分表:eg.以“s”结尾。show tables like “%s”;--表示末尾为s的表。
                     以“s”开头。show tables like “%s”;--表示开头为s的表。
      .查看创建表语句:show create table 表名g  --g等价于分号
                      ----------------------G  --将查到的结构旋转90°纵向。
      .查看表中字段字段信息:desc 表名;
      
    3.对字段操作
      增加
      .增加:alter table 表名 add[colum] 字段名 数据类型 [列属性][位置];
       在指定位置增加:First/After  First指的是加在首行。 alter table student add sd int First; 
                       After 字段名----指加在某字段后面。 alter table student add sd int After age;
      .删除:alter table 表名  drop 字段;
      .修改:alter table 表名 modify 字段名 数据类型 [属性][位置];
            --eg.alter table student modify number char(10) after id;
      重命名:alter table 表名 change 旧 新 数据类型 [属性][位置];
    
    4.数据操作
      增加:insert into 表 values (值列表)()()()......
      删除:delete from 表名 where 
      更新:uptate 表名 set 字段 = 值[where条件]
      查询:查所有---select * from 表名;
            查部分---select 字段,字段,字段 from 表名 where条件;
                     eg.select id,name,sex frpm student where id=1;
      
      
     
      
  • 相关阅读:
    [No0000139]轻量级文本编辑器,Notepad最佳替代品:Notepad++
    [No0000138]软件开发基础知识
    [No0000137]字符编码详解
    [No0000144]深入浅出图解C#堆与栈 C# Heap(ing) VS Stack(ing)理解堆与栈1/4
    [No0000136]6个重要的.NET概念:栈,堆,值类型,引用类型,装箱,拆箱
    [No0000135]程序员修炼之道 Tips
    phpstorm 调试时浏览器显示The requested resource / was not found on this server
    php注解
    phpStorm 配置PHP_CodeSniffer自动检查代码
    php
  • 原文地址:https://www.cnblogs.com/zdcn/p/9130548.html
Copyright © 2011-2022 走看看