Oracle PL\SQL²Ù×÷£¨Î壩
1.ÔÚ±íÖ®¼ä´«ÊäÊý¾Ý
1£©ÀûÓÃINSERT´«ÊäÊý¾Ý
insert into test1 (select name2,age2 from test2);
´ÓÉÏÃæµÄ²Ù×÷¿ÉÒÔ¿´³ö£¬¿Éͨ¹ýSELECTÏòÒ»¸ö±íÖгÉÅúµØÌí¼ÓÊý¾Ý£¬µ«Ó¦×¢Ò⣺Êý¾ÝÀàÐÍÒªÒ»Ö£¬ËùÑ¡ÔñµÄÁÐÊýÓ¦Ò»Ö¡£´ËÓï¾äµÄÓï·¨¸ñʽÈçÏ£º
INSERT INTO table_name (
SELECT statement
) ;
2£©»ùÓÚÒÑÓÐµÄ±í½¨Á¢Ð±í
Ó﷨Ϊ£º
CREATE TABLE new_table_name AS
SELECT statement ;
Íê³ÉÒÔϲÙ×÷,²¢±È½Ïtest1ºÍtest2µÄ±í½á¹¹£º
create table test3 as select * from test2;
2.ÖØÐÂÃüÃû±í
ÕâÏ×÷×öÆðÀ´ºÜÈÝÒ×£¬Óï·¨ÈçÏ£º
RENAME old_table_name TO new_table_name;
Íê³ÉÈçϲÙ×÷£º
rename test3 to tst3;
rename test2 to tst2;
rename test1 to tst1;
3.¸ü¸Ä±íµÄ½á¹¹
1£©Ôö¼ÓÁÐ
ALTER TABLE table_name
ADD new_column_name datetype[NOT NULL]
;
alter table tst1 add csrq date;
alter table tst2 add dz varchar2(20);
desc tst1;
desc tst2;
2£©¸ü¸ÄÁеÄÊý¾ÝÀàÐÍ
ALTER TABLE table_name
MODIFY column_name new_datatype ;
alter table tst1
modify age char(3);
desc tst1;
3£©¸ü¸Ä¿ÕֵѡÏî
ALTER TABLE table_name
MODIFY column_name NOT NULL
;
Íê³ÉÒÔϲÙ×÷, ¹Û²ì±í½á¹¹ÁÐÊý¾ÝÀàÐ͵ı仯£º
alter table tst1
modify name not null;
desc tst1;
alter table tst1
modify name null;
desc tst1;
4.ÊÓͼ
¸ÅÄî: ¶¨ÒåÒ»¸ö²éѯ£¬½«Ëü´æ·Åµ½OracleµÄÊý¾Ý¿âÖУ¬È»ºóÔÊÐíÓû§°´Ãû×Öµ÷Ó㬾ÍÏñÊDZíÒ»Ñù£¨Êµ¼ÊÉϲ¢²»ÊÇ±í£©¡£´ÓÓû§µÄ¹ÛµãÀ´¿´£¬ÊÓͼ¿´ÉÏȥȷʵÏñÒ»¸ö±í£¬Êý¾ÝºÃÏñÊÇ´ÓÕâ¸ö±íÖмìË÷³öÀ´µÄ¡£Æäʵ£¬Êý¾ÝÖ»ÊÇͨ¹ýÕâ¸öÊÓͼÏÔʾ³öÀ´£¬ËüÃÇʵ¼ÊÀ´×ÔÒ»¸ö»ò¶à¸öÆäËûµÄÊý¾ÝÔ´¡£ÊÓͼµÄÒ»ÖÖ×î³£¼ûµÄÓ¦ÓÃÊÇÁ¬½ÓÀ´×ÔÁ½¸ö»ò¶à¸ö±íµÄÊý¾Ý£¬²¢ÒÔÒ»¸ö±ãÓÚÔĶÁµÄÁÐ±í½«ËüÃÇÌṩ¸øÓû§¡£Í¨¹ýÖ¸¶¨¼Ç¼¼ìË÷¹ý³ÌʹÓû§²»±ØÀí½âÔõÑùÁ¬½Ó±í£¬Ê¹´óÁ¿µÄÈ˶¼Äܹ»Ê¹ÓÃÕâЩÊý¾Ý¡£
CREATE OR REPLACE VIEW view_name AS
SELECT statement ;
CREATE VIEW view_name AS
SELECT statement ;
½¨Á¢Ò»¸öÊÓͼ£¬²éѯѧԱ»ù±¾Ç顢ѡÐ޿γ̺ͳɼ¨¡£
create or replace view xyqk_view as
select a.xm ÐÕÃû , a.dh µç»°, c.kcmc ¿Î³ÌÃû³Æ, b.cj ³É¼¨
from xyqkb a, xycjb b, xkb c
where a.xybh = b.xybh and c.k
Ïà¹ØÎĵµ£º
ËäȻѧϰJavaºÜ¾ÃÁË£¬×Ô¼ºÒ²Á¬½Ó¹ýһЩÊý¾Ý¿â£¬±ÈÈçmysqlÖ®ÀàµÄ£¬Èç½ñÄØ£¬Ò²Ñ§Ï°ÁËÒ»¶Îʱ¼äµÄOracle£¬È»¶øÄØ£¬½ñÌìÊÇÎÒµÚÒ»´ÎÁ¬½ÓOracle£¬ºÙºÙ£¬Ó¦¸Ã»¹²»ËãÌ«³Ù°É¡£
½ñÌìÄØ£¬Óе㱿׾£¬´ó¼ÒĪЦ£¡
ÎÒÕâÊÇÒ»¸ö²éѯÀý×Ó
Ê×ÏÈ£¬Ô ......
ʹÓà SQL Server ʼþ̽²éÆ÷µÄ·½°¸
ʹÓà SQL Server ProfilerµÄµÚÒ»²½ÊÇÈ·¶¨¼àÊÓ SQL Server ʵÀýµÄÔÒò¡£±¾Ö÷ÌâÌÖÂÛʹÓà SQL Server ProfilerÊÕ¼¯¸ú×ÙÐÅÏ¢µÄµäÐÍ·½°¸¡£
ʹÓà SQL Server ProfilerµÄµäÐÍ·½°¸°üÀ¨£º
²éÕÒÖ´ÐÐÇé¿ö×î²îµÄ²éѯ¡£
ÀýÈ磬¿ÉÒÔ´´½¨Ò»¸ö²¶»ñÓë TSQL ºÍ Stored Procedure ʼþÀࣨRPC:Completed ......
if exists(select * from master.dbo.sysdatabases where name = 's2723103005')
begin
drop database s2723103005
print 'ÒÑɾ³ýÊý¾Ý¿âs2723103005'
end
create database s2723103005
on primary
(name=His_data,
filename = 'd:\database\his_data.mdf',
siz ......
1.OracleÔõÑù´æ´¢Îı¾
CHARºÍVARCHAR2µÄÇø±ð
•CHAR¶¨³¤×Ö·û´®£¬VARCHAR2±ä³¤×Ö·û´®¡£
•CHAR(n) ¶¨³¤×Ö·û´®£¬n×Ö½Ú£¬nµÄÈ¡Öµ·¶Î§£º1~2000×Ö½Ú¡£
•VARCHAR2(n) ¿É±ä³¤µÄ×Ö·û´®£¬¶¨ÒåʱӦָÃ÷×î´ó³¤¶È£¬È¡Öµ·¶Î§£º1~ 4000×Ö½Ú¡£
2. OracleÔõÑù´æ´¢ÊýÖµ
ÊýÖµÀàÐÍ˵Ã÷£º NUMBER£¨m , n£©
Êý×Ö ......
1.ϵͳ±äÁ¿º¯Êý
£¨1£©SYSDATE
¸Ãº¯Êý·µ»Øµ±Ç°µÄÈÕÆÚºÍʱ¼ä¡£·µ»ØµÄÊÇOracle·þÎñÆ÷µÄµ±Ç°ÈÕÆÚºÍʱ¼ä¡£
select sysdate from dual;
insert into purchase values
(‘Small Widget’,’SH’,sysdate, 10);
insert into purchase values
(‘Meduem Wodget’,’SH’, ......