第19章 插入数据

P132

insert into customers VALUES(NULL,'Pep E.Lapew','100 Main Street',,Los Angeles','CA','90046','USA',NULL,NULL); #customers表中刚好有9个维度(一定要对应上),9个值会对应这9个维度,维度的次序由表定义#

insert into customers (cust_name,cust_address,cust_city,cust_state,cust_zip,cust_country,cust_contact,cust_email) VALUES(NULL,'Pep E.Lapew','100 Main Street',,Los Angeles','CA','90046','USA',NULL,NULL); #把维度列出来,按这个顺序对应后面的值填充到新行#

跑出来对应的结果是这样:

insert into customers(cust_name,cust_address,cust_city,cust_state,cust_zip,cust_country) VALUES('Pep E.Lapew','100 Main Street',‘Los Angeles','CA','90046','USA')

insert into customers(cust_name,cust_address,cust_city,cust_state,cust_zip,cust_country) VALUES('Pep E.Lapew1','100 Main Street1',’Los Angeles1','CA1','90045','USA1');  #同时增加两行,维度和值一一对应#  #是的我没运行出来,不知道是不是版本的问题,还是语句出错了)

insert into customers(cust_name,cust_address,cust_city,cust_state,cust_zip,cust_country) VALUES('Pep E.Lapew','100 Main Street',‘Los Angeles','CA','90046','USA')

,('Pep E.Lapewo','100 Main Streeto',’Los Angeleso','CAo','90045','USA');     #和上面表达的意思是一样#

insert into customers(cust_id,cust_contact,cust_emails,cust_name,cust_address,cust_city,cust_state,cust_zip,cust_country)

select  cust_id,cust_contact,cust_emails,cust_name,cust_address,cust_city,cust_state,cust_zip,cust_country from custnew;

#在custnew里面对应的这些列的数据导入到表customers中,注意这个语句没有了values(‘ ’) #

《mysql必知必会》学习_第19章_20180809_欢的更多相关文章

  1. 《mysql必知必会》学习_第22章_20180809_欢

    第22章:使用视图,视图是虚拟的表,以表形式呈现的是你查询的结果.并不是说在数据库里面真的存在这个表,但是是真的存在这些数据. select cust_name,cust_contact from c ...

  2. 《mysql必知必会》学习_第20章_20180809_欢

    第20章:更新和删除数据 P140 update customers set_emails='elmer@fudd.com' where cust_id=10005; 更新多个列,用逗号隔开.注意被指 ...

  3. 《mysql必知必会》学习_第18章_20180807_欢

    第18章 全文本搜索 P121  #创建一个新表,对表的列进行定义,定义之后,MySQL自动维护该索引# create table productnotes ( note_id  int   NOT ...

  4. 《mysql必知必会》学习_第五章_20180730_欢

    使用的工具是wamp的Mysql. P29 select prod_name from products;  #在表products中选列prod_name,顺寻不是纯粹的随机,但是没有说明排列顺序, ...

  5. 《mysql必知必会》学习_第17章_20180807_欢

    第17章:组合查询 P114 select vend_id ,prod_id,prod_price from products where prod_price <=5 ; select ven ...

  6. 《mysql必知必会》学习_第16章_20180807_欢

    第16章:创建高级联结. P106 select concat(RTrim(vend_name),'(',RTrim(vend_country),')') as vend_title from ven ...

  7. 《mysql必知必会》学习_第15章_20180806_欢

    第15章:联结表 P98 外键:外键为某个表的一列A,同时这一列包含另一个表的主键值B(B属于A,等于或者小于的关系) P99 select vend_name,prod_name,prod_pric ...

  8. 《mysql必知必会》学习_第14章_20180806_欢

    第14章:使用子查询. 子查询是镶嵌在其他查询里面,相当其他的select查询的条件来. P91 select order_num from where prod_id='tnt2';   #检索条件 ...

  9. 《mysql必知必会》学习_第13章_20180803_欢

    第13章:分组过滤. P83 select count(*) as num_prods from products where vend_id=1003; #返回vend_id=1003的产品数目总值 ...

随机推荐

  1. 学习笔记 requests + BeautifulSoup

    第一步:requests get请求 # -*- coding:utf-8 -*- # 日期:2018/5/15 17:46 # Author:小鼠标 import requests url = &q ...

  2. redis-单线程架构

    单线程模型: redis中的数据结构并不全是简单的kv,还有list.hash等复杂的结构,这些结构很可能会进行细粒度的操作,比如在很长的列表偶棉添加一个元素,在hash当中或者删除一个对象,这样的一 ...

  3. python函数作用域,嵌套函数,闭包

    函数作用域                                                                                                ...

  4. java数据类型关系及关系

    java中有常见的基本数据类型和引用数据类型,基本数据类型为四类八种如下 整数型(byte,short,int,long) 浮点型(float,double) 字符型(char) 布尔型(boolea ...

  5. leetcode238

    public class Solution { public int[] ProductExceptSelf(int[] nums) { int[] result = new int[nums.Len ...

  6. leetcode461

    public class Solution { public int HammingDistance(int x, int y) { ]; ]; ; ; do { aryA[i] = x % ;//将 ...

  7. [Linux] traceroute 路由跟踪指令用例

    traceroute是用来跟踪数据包到达网络主机所经过的路由工具.在Linux系统中,称之为traceroute,在Windows中称为tracert. 一条路径上的每个设备traceroute要测3 ...

  8. PHP/TP5 接口设计中异常处理

    PHP提供 Exception 类来处理异常 new Exception('错误信息(默认为空)','错误代码(默认0)','异常链中前一个异常') 然后可以通过 e -> getMessage ...

  9. 0429---每日习题 菲薄纳西数列 正则ip匹配

    #8.打印斐波拉契数列前n项 def fib(n): if n==1 or n==2: return 1 return fib(n-1)+fib(n-2) for i in range(1,9): p ...

  10. 早期自学jQuery-二事件

    本节目录 ----------①鼠标事件 ----------②键盘事件 ----------③表单事件 ----------④文档窗口事件 ----------⑤举例,按下回车键触发事件 事件函数 ...