回覆列表
  • 1 # 80後學渣

    1、資料庫增加資料:

    1)插入單行

    insert [into] <表名> (列名) values (列值)

    例:insert into t_table (name,sex,birthday) values ("開心朋朋","男","1980/6/15")

    2)將現有表資料新增到一個已有表 insert into <已有的新表> (列名) select <原表列名> from <原表名>

    例:insert into t_table ("姓名","地址","電子郵件")

    select name,address,email from t_table

    3)直接拿現有表資料建立一個新表並填充 select <新建表列名> into <新建表名> from <源表名>例:select name,address,email into t_table from strde

    truncate table tongxunlu

    3、資料庫修改資料 update <表名> set <列名=更新值> [where <更新條件>]

    例:update t_table set age=18 where name="藍色小名"

    4、資料庫查詢資料:

    1)精確(條件)查詢select <列名> from <表名> [where <查詢條件表達試>] [order by <排序的列名>[asc或desc]]

    2)查詢所有資料行和列。例:select * from a

    說明:查詢a表中所有行和列

    3)使用like進行模糊查詢

    注意:like運算副只用於字串,所以僅與char和varchar資料型別聯合使用

    例:select * from a where name like "趙%"

    說明:查詢顯示錶a中,name欄位第一個字為趙的記錄

    4)使用between在某個範圍內進行查詢

    例:select * from a where nianling between 18 and 20

    說明:查詢顯示錶a中nianling在18到20之間的記錄

    5)使用in在列舉值內進行查詢

    例:select name from a where address in ("北京","上海","唐山")

    說明:查詢表a中address值為北京或者上海或者唐山的記錄,顯示name欄位

  • 2 # 心靈感想

    01查詢資料,我們使用的是select語句,from關鍵字後面新增要查詢的表名就行了。02更改資料,使用的是update語句,update後面跟的是表名,然後使用set語句來指示更新哪個欄位和欄位的新值。where語句用來限定哪一行或哪幾行的資料需要更新。03插入資料,使用insert into語句,後面跟上表名,和對應的欄位,再使用values關鍵字,為欄位一一賦值。04刪除資料,使用delete from語句,where後面可以指定要刪除的資料。End

  • 中秋節和大豐收的關聯?
  • 水頭損失怎麼計算?