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;
      
      
     
      
  • 相关阅读:
    Linux内核的ioctl函数学习
    两个VLC实现播放串流测试
    嵌入Linux启动配置文件
    Qt/Embedded中使用jpeglib
    Flex中使用TabBar ViewStack 控件不加载问题
    Flex 特殊字符及转义符
    undefined reference to `jpeg_std_error(jpeg_error_mgr*)
    OK6410预览并实现截图操作(RGB565)
    C# 工具条控件设置背景色去除边框
    TeamFoundation Server 使用技巧
  • 原文地址:https://www.cnblogs.com/zdcn/p/9130548.html
Copyright © 2011-2022 走看看