資料庫語法學習

2022-11-29 10:45:05 字數 3280 閱讀 5001

--查詢操作

select *from emp e,dept d where

--將smith的獎金設定為300美元

select *from emp where ename='smith'

update emp set salary=300 where ename='smith'

--將smith的獎金新增300美元

update emp set comm=isnull(0,comm)+300 where empno=7369

update emp set comm=null where empno=7369

--插入部分字段

--語法:insert into tablename(欄位1,欄位2) values (欄位1對應值,欄位2對應值)

--把smith的job改成sales,獎金增加300

insert into emp(job,comm) values('sales',300)

--為king增加乙個mgr:9999

select *from emp where ename='king'

update emp set mgr=9999 where mgr is null

--查詢smith的薪水,工作,所在部門

--select 欄位1,欄位2 from emp where 條件

select salary,job,deptno from emp where ename='smith'

--統計有多少部門編號

--distinct消除完全一樣的行,保留一行

select distinct deptno from emp

--顯示每個員工的年工資

select ename,salary*12+isnull(0,comm)*12 '年工資' from emp

--顯示1982-1-1**職的員工

select *from emp where hiredate>'1982-1-1'

--顯示工資在2000到2500之間的雇員

select *from emp where salary between 1000 and 2500

--顯示首字元為s的員工

--%表示後面的字元全部省略

select *from emp where ename like 's%'

--顯示第三個字元為大寫o的所有員工姓名和工資

--_表示省略乙個字元

select ename,salary from emp where ename like '__o%'

--多表查詢(關聯:兩表連線的橋梁)

--如果兩張表都有相同名字字段,則需要帶表名(別名)

--顯示雇員名,雇員工資及所在部門的名字

select from emp e,dept d where

--顯示部門號為10的部門名、員工名和工資

select from emp e , dept d where and

--顯示部門號為10的部門名、員工名和工資,並按部門名排序(order by)

select *from dept

select from emp e , dept d where and order by

--自連線是指同一張表的連線查詢

--顯示某乙個員工的上級領導的姓名:顯示ford的上級

--分析①顯示ford的上級編號②顯示上級姓名

select mgr from emp where ename='ford'

select ename from emp where empno=(select mgr from emp where ename='ford')

--顯示所有員工的上級領導的姓名:

select *from emp;

select , from emp e1,emp e2 where

--把工資低於1500的雇員工資提高10%

--如果需要改變表中資料值,用update來更新,語法如下

--update tablename set 欄位1=?,欄位2=? where 條件

update emp set salary = salary*1.1 where salary<1500

--插入部分字段

insert into dept(empno,comm)values(7369,300)

--將smith的獎金新增300美元

update emp set comm=300 where empno=7369

--為king增加乙個mgr:9999

update emp set mgr=9999 where mgr is n

ullselect *from emp;

--查詢所有列

select *from emp;

--查詢smith的薪水,工作,所在部門

--select 欄位1,欄位2 from emp where 條件

select salary,job,deptno from emp where ename ='smith'

--統計有多少個部門編號

--select distinct 欄位1 from tablename where 條件

--distinct 消除完全一樣的行,保留一行

select distinct deptno from emp;

--顯示每個員工的年工資

select ename,salary*13 '年工資' from emp;

--年工資=獎金+基本工資

--select ename,salary*13+comm*13 '年工資' from emp;

select ename,salary*13+isnull(comm,0) '年工資' from emp;

--如何查詢1982-1-1**職的員工

select *from emp where hiretime>='1902-1-1'

--顯示工資在2000到2500之間的雇員

select *from emp where salary>=1000 and salary<=2500

select *from emp where salary between 1000 and 2500

--顯示首字元為s的員工

--%表示後面的字元全部省略

select * from emp where ename like 's%'

--顯示第三個字元為大寫o的所有員工姓名和工資

--_表示省略乙個字元

select ename,salary from emp where ename like '__o%'

標準南韓語語法學習

標準南韓語第一冊語法彙總 接在表示場所的名詞後表示去某處,詢問用 去哪兒?去學校.場所名詞後 在某處 做什麼 表示動作進行的場所 在學校學習.謂詞後共動式終結詞尾 吧表示尊敬共動語氣走吧.讀吧 動詞後命令式終結詞尾 請 表示尊敬語氣,前者更尊敬 請看 請讀 謂詞前,後 不,沒表示否定沒看報紙 名詞代...

ABAP語法 資料庫更新

概覽要有效地進行程式設計資料庫更新,程式設計師必須主要關注於 內容sap 資料庫環境 r 3 體系結構 概述 sap 系統中的事務 更新繫結介紹 sap 鎖定介紹 更新程式設計技術 維護資料庫完整性 優化事務效能 未繫結的更新 在對話任務中的繫結更新 更新任務中的繫結更新 後台任務中的繫結更新 co...

日語語法學習 日語一級語法總結測試

私 知事実 1.2.3.限 4.電気工學 世界 彼 名聲 高 1.2.3.4.十年間一日 休 言 練習 今日 彼 1.2.3.4.菓子 怒 大人 人 1.2.3.4.5.本日 私 會長職 辭思 1.限 2.成 3.4.論 何 日本 世界的 問題 1.2.3.一國 4.一體 競技場 五萬人 客 収容 ...