1.建表
CREATE TABLE orderdetail ( id number(11) NOT NULL PRIMARY KEY, orders_id number(11) NOT NULL, items_id number(11) NOT NULL, items_num number(11) DEFAULT NULL, CONSTRAINT FK_orderdetail_1 FOREIGN KEY (orders_id) REFERENCES orders (id), CONSTRAINT FK_orderdetail_2 FOREIGN KEY (items_id) REFERENCES items (id));
2.插入數(shù)據(jù)
insert into users(id,username,birthday,sex,address) values (10,'張三',to_date('2014-02-14','yyyy-mm-dd'),'1','北京市');
3.Oracle的保留字可以在以DBA身份登錄的情況下,通過“select * from v$reserved_Words order by keyword asc”語句來獲得。
4.建立表空間
create tablespace 表空間名 datafile 'D:/java/Oracle/product/10.1.0/oradata/zznorcl/hoteldata.dbf'//為表空間存放的物理路徑size 200m //設(shè)置空間初始值大小autoextend on next 10m maxsize unlimited; //表空間自動增長,每次變大 ~沒有最大限制eg:create tablespace user_spacedatafile 'D:/oracle/hoteldata.dbf'size 200m autoextend on next 10m maxsize unlimited; 5.連接數(shù)據(jù)庫
sqlplus 用戶名/密碼@ip地址/數(shù)據(jù)庫名 eg:sqlplus sys/sys@192.168.64/orcl
6.導(dǎo)出表
(1)將數(shù)據(jù)庫TEST完全導(dǎo)出,用戶名system 密碼manager 導(dǎo)出到D:/daochu.dmp中exp system/manager@TEST file=d:/daochu.dmp full=y (2) 將數(shù)據(jù)庫中system用戶與sys用戶的表導(dǎo)出exp system/manager@TEST file=d:/daochu.dmp owner=(system,sys)
7.導(dǎo)入表
(1)將D:/daochu.dmp 中的數(shù)據(jù)導(dǎo)入TEST數(shù)據(jù)庫中。imp system/manager@TEST file=d:/daochu.dmp imp sys/sys@TEST full=y file=file= d:/data/newsmgnt.dmp ignore=y 上面可能有點問題,因為有的表已經(jīng)存在,然后它就報錯,對該表就不進行導(dǎo)入。在后面加上ignore=y 就可以了。
(2)將d:/daochu.dmp中的表table1 導(dǎo)入imp system/manager@TEST file=d:/daochu.dmp tables=(table1)
新聞熱點
疑難解答