基本SQL 语句操作数据增删查改
1、创建数据库: create database <数据库名>。
如:create database student;
2、连接到一个已经存在的数据库: use <数据库名>;
如:use student;
3、删除数据库:drop database <数据库名>。
如: drop database student;
4、创建表:create table <表名>(<列名><列的数据类型>[<列的约束>])
如:create table stuInfo(stuId int primary key,stuName varchar(20) not null)
5、删除表: drop table <表名>
如: drop table stuInfo;
6、改动表:alter table
给表加入新列: alter table <表名> add <列名><列的数据类型>;
加入多列,中间用逗号隔开
如:alter table stuInfo add stuGender varchar(10)
改动某列的数据类型:alter table <表名> modify <列名><新数据类型>
如:alter table stuInfo modify stuGender int
改动列名:alter table <表名> change <老列名><新列名><数据类型>
如:alter table stuInfo change stuName stuAddress varchar(30)
删除列:alter table <表名> drop <列名>
如: alter table stuInfo drop stuGender
7、将创建的表的语句反向导出: show create table <表名>
8、查询表的全部内容:select * from <表名>
查询表的部分内容: select <列名列表> from <表名>
9、查询表结构:show columns from <表名>
10、插入单行数据:insert into <表名>(<列名列表>) values(<值列表>)
11、插入多行数据:作用相当于将数据从一个表拷贝到还有一个表
insert into <表名> (列名列表) select <select语句>
如将stuInfo表中的全部的学生姓名拷贝到students表中的stuName列中:insert into students(stuName) select stuName from stuInfo
12、删除数据:delete from <表名> where<过滤条件>
如删除stuID为4的人的数据:delete from stuInfo where stuId=4
基本SQL 语句操作数据增删查改的更多相关文章
- 常用SQL语句(增删查改、合并统计、模糊搜索)
转自:http://www.cnblogs.com/ljianhui/archive/2012/08/13/2695906.html 常用SQL语句 首行当然是最基本的增删查改啦,其中最重要的是查. ...
- SQL语句的增删查改
一.增:有2种方法 1.使用insert插入单行数据: 语法:insert [into] <表名> [列名] values <列值> 例:insert into Strdent ...
- sql基本的增删查改语句
1.增---用于向表中插入新的行/数据 语法:insert into 表名(值1,值2,值3...) values(值1,值2,值3,...) 或者 语法:insert [into] <表名&g ...
- MySQL学习-入门语句以及增删查改
1. SQL入门语句 SQL,指结构化查询语言,全称是 Structured Query Language,是一种 ANSI(American National Standards Institute ...
- Mybatis 的动态SQL,批量增删查改
个人博客网:https://wushaopei.github.io/ (你想要这里多有) 批量增删改的接口: public interface BookService { //批量增加 int ...
- SQL基本之增删查改操作
1.为表添加主键 alter table <tablename> add primary key(col); 主键添加前: 主键添加后: 2.插入数据 insert into <ta ...
- ADO.NET教程(2)实现增删查改
声明一个类,在类中实现增删查改的方法 public class AdoNet { //声明连接字符串 public string Sqlstr = "data source={0};data ...
- EF各版本增删查改及执行Sql语句
自从我开始使用Visual Studio 也已经经历了好几个版本了,而且这中间EF等框架的改变也算是比较多的.本篇文章记录下各个版本EF执行Sql语句和直接进行增删查改操作的区别,方便自己随时切换版本 ...
- EF增删查改加执行存储过程和sql语句,多种方法汇总
ActionUrl c = new ActionUrl() { ActionName="test", RequestUrl="/123/123", SubTim ...
随机推荐
- Ubuntu 16.04 LTS上git提交出现警告Warning: Permanently added 'github.com,52.74.223.119' (RSA) to the list of known hosts. 的解决方法
问题: Ubuntu 16.04 LTS执行 git pull时总会出现以下警告: Warning: Permanently added 'github.com,52.74.223.119' (RSA ...
- 关于logging模块重复问题
logger对象配置 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 import logging # 获取一个新日志logger = ...
- win7定时关机
菜单>附件>系统工具>任务计划程序>创建基本任务 alt+r>cmd>shutdown/? 查看相关参数 /l 注销 /s 关机 /r 重启 /g 重启,重启后,重 ...
- 四丶人生苦短,我用python【第四篇】
1 基本数据类型 数字 int 字符串 str 布尔值 bool 列表 list 元组 tuple 字典 dict >>>type( ...
- 面试准备——Zookeeper
转自https://www.cnblogs.com/shan1393/p/9479109.html 1. Zookeeper是什么框架 分布式的.开源的分布式应用程序协调服务,原本是Hadoop.HB ...
- 论文《Piexel Recurrent Nerual Network》总结
论文<Piexel Recurrent Nerual Network>总结 论文:<Pixel Recurrent Nerual Network> 时间:2016 作者:Aar ...
- hlgoj1881
#include <stdio.h> +]; int main(){ int l,m; int i,j; int sign; num[]=; num[]=; while(~scanf(&q ...
- 九度oj 题目1369:字符串的排列
题目描述: 输入一个字符串,按字典序打印出该字符串中字符的所有排列.例如输入字符串abc,则打印出由字符a,b,c所能排列出来的所有字符串abc,acb,bac,bca,cab和cba. 输入: 每个 ...
- 【转】Eric's并发用户数估算与Little定律的等价性
转自:http://www.cnblogs.com/hundredsofyears/p/3360305.html 在国内性能测试的领域有一篇几乎被奉为大牛之作的经典文章,一个名叫Eric Man Wo ...
- 【Openjudge】岛屿(并查集)
题目链接 此题是并查集.考虑到水位不断上涨,所以将时间倒转.先统计最后一天的联通块个数,每一天浮出水面的块进行计算.复杂度O(玄学). 代码如下 #include<cstdio> #inc ...