『壹』 備忘錄的記錄格式應該怎麼寫
備忘錄在公文函件中,它的等級是比較低的,主要用來提醒、督促對方,或就某個問題提出自己的意見或看法。在業務上,它一般用來補充正式文件的不足。
它的內容可以分為以下幾項:書端(Heading); 收文人的姓名、頭銜、地址(Addressee』s Name,Title,Address); 稱呼(Salutation)。
事因(Subject); 正文(Body) ; 結束語(Complimentary Close); 署名(Signature)。
範文如下圖:
(1)sql備忘單怎麼寫擴展閱讀:
備忘錄談判雙方共同記載有關談判內容的書面文件,對雙方當事人都有法律約束力。在項目談判或者合同談判、履行過程中,為解決某些方面的問題,當事人要進行多次的談判,為了了解談判的進程,需要通過書面的形式把雙方討論的問題明確下來,以便於在下一次談判時參考。
有的備忘錄還具有可執行的效力,這樣的備忘錄往往是合同的組成部分或者債權債務的依據。備忘錄的主要內容包括:第一,備忘錄形成經過:第二,雙方討論的主要問題;第三,形成共識的問題;第四,存在分歧的問題;第五,各方的責任;第六,雙方當事人的簽字。
製作備忘錄的基本要求是:第一,簡明扼要地寫明備忘錄形成的時間、地點、參加人、討論的主題等基本情況;第二,對於形成共識的問題要求寫明是什麼問題、怎麼處理此問題、誰對此問題負責、負何種責任等情況;第三,對於分歧問題也要寫明雙方不同觀點及理由。
『貳』 簡單的SQL語言怎麼寫
1.select * from tablename;
2.selct 選修課程 from tablename;
3.select 姓名 from tablename where 年齡<21;
4.select 年齡 from tablename where 姓名 like "張%";
5.select * from tablename order by 年齡;
『叄』 怎樣用C語言編寫一個備忘錄
A 設計合適的數據結構,所謂錄入查看即,將合適的數據寫入這些數據結構。
B 選擇合適的搜索演算法,最簡單的是遍歷。模糊查詢比較麻煩,做起來最簡單的是利用sql/linq,但需要資料庫基礎;想起來最簡單是用兩個指針指向Str1 Str2,用Str2首字母與Str1比較,相同則2個指針同時後移繼續比較,失敗則向後移動Str1的指針繼續比較。每次比較不同時將Str2指針重新指向Str2首部。
C 增刪改查,修改數據結構內容,基本沒難度。
* 如果願意學習or了解資料庫可用合適的資料庫和sql語句解決,會相當的簡單。
沒有定時器的情況下提醒可以用循環+ctime獲取時間(否則是timer),但切記如果用循環的話,需要加上短暫的Sleep()(頭文件windows.h),否則cpu消耗會很恐怖。
思路就這樣了,自己動手吧,計算機系學生不想廢掉就多動動手有好處。
如果決定自己動手了有疑難點可以接著問,如果想等現成的代碼請無視。
『肆』 這個簡單的SQL語言怎麼寫好呢
在本地伺服器
create datebase link link_guizhou using guizhou;
在貴州伺服器
alter database rename global_name to ora2000;
這樣就可以在本地資料庫查詢遠程資料庫的數據了
select * from magazineitem where mobileid='13811681341'@link_guizhou;
---------------在Oracle中實現資料庫的復制-------------------------
在Internet上運作資料庫經常會有這樣的需求:把遍布全國各城市相似的資料庫應用統一起來,一個節點的數據改變不僅體現在本地,還反映到遠端。復制技術給用戶提供了一種快速訪問共享數據的辦法。
一、實現資料庫復制的前提條件
1、資料庫支持高級復制功能
您可以用system身份登錄資料庫,查看v$option視圖,如果其中Advanced replication為TRUE,則支持高級復制功能;否則不支持。
2、資料庫初始化參數要求
①、db_domain = test.com.cn
指明資料庫的域名(默認的是WORLD),這里可以用您公司的域名。
②、global_names = true
它要求資料庫鏈接(database link)和被連接的資料庫名稱一致。
現在全局資料庫名:db_name+」.」+db_domain
③、有跟資料庫job執行有關的參數
job_queue_processes = 1
job_queue_interval = 60
distributed_transactions = 10
open_links = 4
第一行定義SNP進程的啟動個數為n。系統預設值為0,正常定義范圍為0~36,根據任務的多少,可以配置不同的數值。
第二行定義系統每隔N秒喚醒該進程一次。系統預設值為60秒,正常范圍為1~3600秒。事實上,該進程執行完當前任務後,就進入睡眠狀態,睡眠一段時間後,由系統的總控負責將其喚醒。
如果修改了以上這幾個參數,需要重新啟動資料庫以使參數生效。
二、實現資料庫同步復制的步驟
假設在Internet上我們有兩個資料庫:一個叫深圳(shenzhen),一個叫北京(beijing)。
具體配置見下表:
資料庫名 shenzhen beijing
資料庫域名 test.com.cn test.com.cn
資料庫sid號 shenzhen beijing
Listener埠號 1521 1521
伺服器ip地址 10.1.1.100 10.1.1.200
1、確認兩台資料庫之間可以互相訪問,在tnsnames.ora里設置資料庫連接字元串。
①、例如:深圳這邊的資料庫連接字元串是以下的格式
beijing =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.1.1.200)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = beijing)
)
)
運行$tnsping beijing
出現以下提示符:
Attempting to contact (ADDRESS=(PROTOCOL=TCP)(HOST=10.1.1.200)(PORT=1521))
OK(n毫秒)
表明深圳資料庫可以訪問北京資料庫。
②、在北京那邊也同樣配置,確認$tnsping shenzhen 是通的。
2、改資料庫全局名稱,建公共的資料庫鏈接。
①、用system身份登錄shenzhen資料庫
SQL>alter database rename global_name to shenzhen.test.com.cn;
用system身份登錄beijing資料庫:
SQL>alter database rename global_name to beijing.test.com.cn;
②、用system身份登錄shenzhen資料庫
SQL>create public database link beijing.test.com.cn using 'beijing';
測試資料庫全局名稱和公共的資料庫鏈接
SQL>select * from [email protected];
返回結果為beijing.test.com.cn就對了。
用system身份登錄beijing資料庫:
SQL>create public database link shenzhen.test.com.cn using 'shenzhen';
測試資料庫全局名稱和公共的資料庫鏈接
SQL>select * from [email protected];
返回結果為shenzhen.test.com.cn就對了。
3、建立管理資料庫復制的用戶repadmin,並賦權。
①、用system身份登錄shenzhen資料庫
SQL>create user repadmin identified by repadmin default tablespace users temporary tablespace temp;
SQL>execute dbms_defer_sys.register_propagator('repadmin');
SQL>grant execute any procere to repadmin;
SQL>execute dbms_repcat_admin.grant_admin_any_repgroup('repadmin');
SQL>grant comment any table to repadmin;
SQL>grant lock any table to repadmin;
②、同樣用system身份登錄beijing資料庫,運行以上的命令,管理資料庫復制的用戶repadmin,並賦權。
說明:repadmin用戶名和密碼可以根據用戶的需求自由命名。
4、在資料庫復制的用戶repadmin下創建私有的資料庫鏈接。
①、用repadmin身份登錄shenzhen資料庫
SQL>create database link beijing.test.com.cn connect to repadmin identified by repadmin;
測試這個私有的資料庫鏈接:
SQL>select * from [email protected];
返回結果為beijing.test.com.cn就對了。
②、用repadmin身份登錄beijing資料庫
SQL>create database link shenzhen.test.com.cn connect to repadmin identified by repadmin;
測試這個私有的資料庫鏈接
SQL>select * from [email protected];
返回結果為shenzhen.test.com.cn就對了。
5、創建或選擇實現資料庫復制的用戶和對象,給用戶賦權,資料庫對象必須有主關鍵字。
假設我們用ORACLE里舉例用的scott用戶,dept表。
①、用internal身份登錄shenzhen資料庫,創建scott用戶並賦權
SQL>create user scott identified by tiger default tablespace users temporary tablespace temp;
SQL>grant connect, resource to scott;
SQL>grant execute on sys.dbms_defer to scott;
②、用scott身份登錄shenzhen資料庫,創建表dept
SQL>create table dept
(deptno number(2) primary key,
dname varchar2(14),
loc varchar2(13) );
③、如果資料庫對象沒有主關鍵字,可以運行以下SQL命令添加:
SQL>alter table dept add (constraint dept_deptno_pk primary key (deptno));
④、在shenzhen資料庫scott用戶下創建主關鍵字的序列號,范圍避免和beijing的沖突。
SQL> create sequence dept_no increment by 1 start with 1 maxvalue 44 cycle nocache;
(說明:maxvalue 44可以根據應用程序及表結構主關鍵字定義的位數需要而定)
⑤、在shenzhen資料庫scott用戶下插入初始化數據
SQL>insert into dept values (dept_no.nextval,'accounting','new york');
SQL>insert into dept values (dept_no.nextval,'research','dallas');
SQL>commit;
⑥、在beijing資料庫那邊同樣運行以上①,②,③
⑦、在beijing資料庫scott用戶下創建主關鍵字的序列號,范圍避免和shenzhen的沖突。
SQL> create sequence dept_no increment by 1 start with 45 maxvalue 99 cycle nocache;
⑧、在beijing資料庫scott用戶下插入初始化數據
SQL>insert into dept values (dept_no.nextval,'sales','chicago');
SQL>insert into dept values (dept_no.nextval,'operations','boston');
SQL>commit;
6、創建要復制的組scott_mg,加入資料庫對象,產生對象的復制支持
①、用repadmin身份登錄shenzhen資料庫,創建主復制組scott_mg
SQL> execute dbms_repcat.create_master_repgroup('scott_mg');
說明:scott_mg組名可以根據用戶的需求自由命名。
②、在復制組scott_mg里加入資料庫對象
SQL>execute dbms_repcat.create_master_repobject(sname=>'scott',oname=>'dept', type=>'table',use_existing_object=>true,gname=>'scott_mg');
參數說明:
sname 實現資料庫復制的用戶名稱
oname 實現資料庫復制的資料庫對象名稱
(表名長度在27個位元組內,程序包名長度在24個位元組內)
type 實現資料庫復制的資料庫對象類別
(支持的類別:表,索引,同義詞,觸發器,視圖,過程,函數,程序包,程序包體)
use_existing_object true表示用主復制節點已經存在的資料庫對象
gname 主復制組名
③、對資料庫對象產生復制支持
SQL>execute dbms_repcat.generate_replication_support('scott','dept','table');
(說明:產生支持scott用戶下dept表復制的資料庫觸發器和程序包)
④、確認復制的組和對象已經加入資料庫的數據字典
SQL>select gname, master, status from dba_repgroup;
SQL>select * from dba_repobject;
7、創建主復制節點
①、用repadmin身份登錄shenzhen資料庫,創建主復制節點
SQL>execute dbms_repcat.add_master_database
(gname=>'scott_mg',master=>'beijing.test.com.cn',use_existing_objects=>true, _rows=>false, propagation_mode => 'asynchronous');
參數說明:
gname 主復制組名
master 加入主復制節點的另一個資料庫
use_existing_object true表示用主復制節點已經存在的資料庫對象
_rows false表示第一次開始復制時不用和主復制節點保持一致
propagation_mode 非同步地執行
②、確認復制的任務隊列已經加入資料庫的數據字典
SQL>select * from user_jobs;
8、使同步組的狀態由停頓(quiesced )改為正常(normal)
①、用repadmin身份登錄shenzhen資料庫,運行以下命令
SQL> execute dbms_repcat.resume_master_activity('scott_mg',false);
②、確認同步組的狀態為正常(normal)
SQL> select gname, master, status from dba_repgroup;
③、如果這個①命令不能使同步組的狀態為正常(normal),可能有一些停頓的復制,運行以下命令再試試(建議在緊急的時候才用):
SQL> execute dbms_repcat.resume_master_activity('scott_mg',true);
9、創建復制資料庫的時間表,我們假設用固定的時間表:10分鍾復制一次。
①、用repadmin身份登錄shenzhen資料庫,運行以下命令
SQL>begin
dbms_defer_sys.schele_push (
destination => 'beijing.test.com.cn',
interval => 'sysdate + 10/1440',
next_date => sysdate);
end;
/
SQL>begin
dbms_defer_sys.schele_purge (
next_date => sysdate,
interval => 'sysdate + 10/1440',
delay_seconds => 0,
rollback_segment => '');
end;
/
②、用repadmin身份登錄beijing資料庫,運行以下命令
SQL>begin
dbms_defer_sys.schele_push (
destination => ' shenzhen.test.com.cn ',
interval => 'sysdate + 10 / 1440',
next_date => sysdate);
end;
/
SQL>begin
dbms_defer_sys.schele_purge (
next_date => sysdate,
interval => 'sysdate + 10/1440',
delay_seconds => 0,
rollback_segment => '');
end;
/
10、添加或修改兩邊資料庫的記錄,跟蹤復制過程
如果你想立刻看到添加或修改後資料庫的記錄的變化,可以在兩邊repadmin用戶下找到push的job_number,然後運行:
SQL>exec dbms_job.run(job_number);
三、異常情況的處理
1、檢查復制工作正常否,可以在repadmin 用戶下查詢user_jobs
SQL>select job,this_date,next_date,what, broken from user_jobs;
正常的狀態有兩種:
任務閑——this_date為空,next_date為當前時間後的一個時間值
任務忙——this_date不為空,next_date為當前時間後的一個時間值
異常狀態也有兩種:
任務死鎖——next_date為當前時間前的一個時間值
任務死鎖——next_date為非常大的一個時間值,例如:4001-01-01
這可能因為網路中斷照成的死鎖
解除死鎖的辦法:
$ps –ef|grep orale
找到死鎖的刷新快照的進程號ora_snp*,用kill –9 命令刪除此進程
然後進入repadmin 用戶SQL>操作符下,運行命令:
SQL>exec dbms_job.run(job_number);
說明:job_number 為用select job,this_date,next_date,what from user_jobs;命令查出的job編號。
2、增加或減少復制組的復制對象
①、停止主資料庫節點的復制動作,使同步組的狀態由正常(normal)改為停頓(quiesced )
用repadmin身份登錄shenzhen資料庫,運行以下命令
SQL>execute dbms_repcat.suspend_master_activity (gname => 'scott_mg');
②、在復制組scott_mg里加入資料庫對象,保證資料庫對象必須有主關鍵字。
SQL>execute dbms_repcat.create_master_repobject(sname=>'scott',oname=>'emp', type=>'table',use_existing_object=>true,gname=>'scott_mg');
對加入的資料庫對象產生復制支持
SQL>execute dbms_repcat.generate_replication_support('scott','emp','table');
③、在復制組scott_mg里刪除資料庫對象。
SQL>execute dbms_repcat.drop_master_repobject ('scott','dept','table');
④、重新使同步組的狀態由停頓(quiesced )改為正常(normal)。
SQL> execute dbms_repcat.resume_master_activity('scott_mg',false);
『伍』 這SQL怎樣寫
如果你的表中有關鍵字或者序號之類的(如:id),用方法一
--------------------------------------------------------------
/*方法一*/
select 品種, 數量, 價格, 金額,
(select SUM(金額) from 表名 B where B.id <= A.id and B.品種 = A.品種) as 合計金額,
((select SUM(金額) from 表名 B where B.id <= A.id and B.品種 = A.品種) /
(select SUM(數量) from 表名 B where B.id <= A.id and B.品種 = A.品種)) as 平均價格
from 表名 A
---------------------------------------------------
如果沒有序號或關鍵字之類的用下面的方法
/*方法二*/
select identity(int,1,1) as id, * into #t from 表名2
select 品種, 數量, 價格, 金額,
(select Sum(金額) from #t B where B.id <= A.id and B.品種 = A.品種) as 合計金額,
((select Sum(金額) from #t B where B.id <= A.id and B.品種 = A.品種) /
(select SUM(數量) from 表名 B where B.id <= A.id and B.品種 = A.品種))
as 平均價格
from #t A
drop table #t
『陸』 這個SQL如何寫
CREATE TABLE #OrderForm (
FormCode VARCHAR(20),
WebSourceUserName VARCHAR(20),
OrigOrder INT,
PostTime DATETIME,
OrderType INT
);
INSERT INTO #OrderForm
SELECT '211084349830', 'hao123mp', 0, '2011-08-12 14:40:25.200', 1;
CREATE TABLE #OrderDetail (
FormCode VARCHAR(20),
ProctCode VARCHAR(20),
ProctName VARCHAR(80),
SellPrice DECIMAL(8,2)
)
INSERT INTO #OrderDetail
SELECT '211084349830', '00274973', '百搭牛仔七分褲W032 牛仔藍', 99.00 UNION ALL
SELECT '211084349830', '00326416', 'TIGER七分袖襯衫 淺咖色', 119.00 UNION ALL
SELECT '211084349830', '00410788', '經典迷彩短袖T恤 迷彩色', 49.00;
CREATE TABLE #ReturnsForm (
ReturnsCode VARCHAR(20),
FormCode VARCHAR(20)
);
INSERT INTO #ReturnsForm
SELECT '0303TH11081500482', '211084349830';
CREATE TABLE #ReturnsDetail( --退貨詳情表
ReturnsCode VARCHAR(20),
ProctCode VARCHAR(20),
ProctName VARCHAR(80),
SellPrice DECIMAL(8,2)
);
INSERT INTO #ReturnsDetail
SELECT '0303TH11081500482', '00274973', '百搭牛仔七分褲W032 牛仔藍', 99.00 UNION ALL
SELECT '0303TH11081500482', '00326416', 'TIGER七分袖襯衫 淺咖色', 119.00;
go
With SaleOutCTE AS
(
SELECT
odf.WebSourceUserName,
odf.FormCode,
SUM(SellPrice) AS SumSellPrice
FROM
#OrderForm odf
JOIN #OrderDetail od
ON (odf.FormCode = od.FormCode)
WHERE
WebSourceUserName = 'hao123mp'
GROUP BY
odf.WebSourceUserName,
odf.FormCode
),
ReturnBackCTE AS
(
SELECT
rf.FormCode,
SUM(SellPrice) AS SumSellPrice
FROM
#ReturnsForm rf
JOIN #ReturnsDetail rd
ON (rf.ReturnsCode = rd.ReturnsCode)
WHERE
EXISTS (
SELECT 1
FROM #OrderForm odf
WHERE
rf.FormCode = odf.FormCode
AND odf.WebSourceUserName = 'hao123mp'
)
GROUP BY
rf.FormCode
)
SELECT
WebSourceUserName,
SUM(SaleOutCTE.SumSellPrice) AS 銷售,
SUM(ISNULL(ReturnBackCTE.SumSellPrice, 0)) AS 退貨,
SUM(SaleOutCTE.SumSellPrice)
- SUM(ISNULL(ReturnBackCTE.SumSellPrice, 0)) as 銷售額
FROM
SaleOutCTE
LEFT JOIN ReturnBackCTE
ON (SaleOutCTE.FormCode = ReturnBackCTE.FormCode)
GROUP BY
WebSourceUserName
go
WebSourceUserName 銷售 退貨 銷售額
hao123mp 267.00 218.00 49.00
(1 行受影響)
『柒』 sql中怎麼查詢表中所有不同日期的單,該怎麼寫.
select top(1) * from table where id = (select * from table where time<'2010-02-28' order by time desc)
這樣就可以了。首先查出所有小於'2010-02-28' 這個時間的單子,然後倒敘排列。這樣比'2010-02-16'這個單子就排在第一了。然後在取第一張單子。也就是'2010-02-16'了。
『捌』 SQL語句應該怎麼寫
select t.*,a.name as 起點,b.name as 終點 from ticket t inner join city a on t.起點ID=a.id inner join city b on t.終點ID=b.id
where t.起點ID=表單傳入的值a and t.終點id=表單傳入的值b
『玖』 sql常用語句寫法
SQL 基本操作命令 創建資料庫create database 資料庫名切換資料庫use database 資料庫名刪除資料庫drop database 資料庫名 將資料庫設為只讀execute sp_dboption '資料庫名','rend only','true' 將資料庫設為自動收縮execute sp_dboption '資料庫名','autoshrink','true'將資料庫設為單獨訪問execute sp_dboption '資料庫名','single user' 收縮資料庫:dbcc shrinkdatabase(資料庫名,未用空間百分比) 創建表create table 表名(列名 數據類型,列名 數據類型) 建表時創建主鍵create table 表名(列名 數據類型 primary key,列名 數據類型)建表後創建主鍵alter table 表名 add constraint pk_表名 primary key(列名) 建表後刪除主鍵alter table 表名 drop constraint pk_表名 建表時創建唯一約束create table 表名(列名 數據類型 unique,列名 數據類型)建表後創建唯一約束alter table 表名 add constraint u_表名 unique(列名) 建表後刪除唯一約束alter table 表名 drop constraint u_表名 建表時創建檢查約束create table 表名(列名 數據類型 check(條件),列名 數據類型)建表後創建檢查約束alter table 表名 add constraint ck_表名 check(條件) 建表後刪除檢查約束alter table 表名 drop constraint ck_表名 建表時創建默認約束create table 表名(列名 數據類型 default(默認值),列名 數據類型)建表後創建默認約束alter table 表名 add constraint df_表名 default(默認值) for 列名 建表後刪除默認約束alter table 表名 drop constraint df_表名 建表時創建外鍵約束create table 表名(列名 數據類型 foreign key references 外表名(主鍵),列名 數據類型)建表後創建外鍵約束alter table 表名 add constraint fk_表名 foreign key(列名) references 外表名(主鍵) 建表後刪除外鍵約束alter table 表名 drop constraint fk_表名 刪除表drop table 表名設置列值自動編號create table 表名(列名 數據類型 int identity(起始值,步長),列名 數據類型) 修改表中列的數據類型alter table 表名[alter column 列名 數據類型]在表中添加一個新列alter table 表名[add 列名 數據類型]刪除表中的某一列alter table 表名[drop column 列名] 輸入數據insert into 表名 values(對應列的值) 更新數據update 表名 set 新值 where 條件刪除數據delete from 表名 where 條件刪除表中所有數據truncate table 表名 將現有表中的數據添加到另一個表insert 目標表名 select 源表列名 from 源查詢所有數據select * from 表名按條件查詢數據select * from 表名 where 條件 按條件查詢某列不重復數據select distinct 列名 from 表名 where 條件按升序排列查詢結果select * from 表名 order by 列名按降序排列查詢結果select * from 表名 order by 列名 desc 按條件查詢數據並排序select * from 表名 where 條件 order by 列名 在查詢結果中自定義列名select 新列名=原列名 from 表名 where 條件在查詢結果中返回最前面的行select top 行數 * from 表名在查詢結果中返回最前面的行數的百分比select top 百分比 percent * from 表名查詢列中所有數值的和select 新列名=sum(列名) from 表名 where 條件查詢列中所有數值的平均值select 新列名=avg(列名) from 表名 where 條件查詢列中非空值的數目select 新列名=count(列名) from 表名查詢表中非空值的數目select 新列名=count(*) from 表名查詢列中的最大值select 新列名=max(列名) from 表名查詢列中的最小值select 新列名=min(列名) from 表名對查詢結果按條件進行分組select 聚合函數(列名) from 表名 group by 列名 having 條件模糊查詢select * from 表名 where 列名 like 『字元通配符』查詢表中包含指定值的所有行select * from 表名 where 列名 in ('值')查詢表中不包含指定值的所有行select * from 表名 where 列名 not in ('值')查詢表中列的數值在數值1到數值2之間的所有行select * from 表名 where 列名 between 數值1 and 數值2查詢表1和表2中包含相同列的所有行select * from 表1 inner join 表2 on 表1.列=表2.列 where 條件 我空間里有,備忘用的