set heading off
set term off
set echo off
set feedback off
set pagesize 0
spool AllObjectsDrop.sql
SELECT 'DROP DATABASE LINK ' || OBJECT_NAME || ';' FROM USER_OBJECTS WHERE OBJECT_TYPE = 'DATABASE LINK';
SELECT 'DROP TYPE ' || OBJECT_NAME || ';' FROM USER_OBJECTS WHERE OBJECT_TYPE = 'TYPE';
SELECT 'DROP TRIGGER ' || OBJECT_NAME || ';' FROM USER_OBJECTS WHERE OBJECT_TYPE = 'TRIGGER';
select 'drop view '||view_name||';' from user_views;
select 'drop sequence '||sequence_name|| ';'from user_sequences;
select 'DROP MATERIALIZED VIEW ' || MVIEW_NAME || ';' FROM user_mviews;
select 'drop table '||table_name|| ';'from user_tables;
select 'drop procedure '||OBJECT_NAME|| ';'from USER_OBJECTS where OBJECT_TYPE = 'PROCEDURE';
select 'drop function '||OBJECT_NAME|| ';'from USER_OBJECTS where OBJECT_TYPE = 'FUNCTION';
select 'drop package '||OBJECT_NAME|| ';'from USER_OBJECTS where OBJECT_TYPE = 'package';
select 'drop synonym '||OBJECT_NAME||';' from USER_OBJECTS where OBJECT_TYPE = 'SYNONYM';
spool off
2013年3月8日 星期五
oracle DROP all objects
2013年2月27日 星期三
VitualBox調整磁碟空間
VBoxManage是VitualBox的指令工具 利用modifyhd指令跟resize參數就可以調整虛擬磁區的大小
路徑可以有空白不過需要用雙引號括起來 resize參數的單位是MB
路徑可以有空白不過需要用雙引號括起來 resize參數的單位是MB
VBoxManage modifyhd "/path/to/dvi/file" --resize 50000
2013年2月24日 星期日
2013年2月23日 星期六
Oracle 清除所有Objects
begin
-- Drop Tables
FOR REC IN (
SELECT table_name
FROM user_tables
WHERE NOT EXISTS(SELECT 1 FROM USER_VIEWS WHERE VIEW_NAME = TABLE_NAME)
and NOT EXISTS(SELECT 1 FROM USER_MVIEWS WHERE MVIEW_NAME = TABLE_NAME)
)
LOOP
BEGIN
EXECUTE IMMEDIATE 'DROP TABLE ' || REC.table_name;
EXCEPTION
WHEN OTHERS THEN
IF SQLCODE != -942 THEN
RAISE;
END IF;
END;
END LOOP;
-- VIEW
FOR REC IN (
SELECT VIEW_NAME
FROM user_views
)
LOOP
BEGIN
EXECUTE IMMEDIATE 'DROP VIEW ' || REC.VIEW_NAME;
EXCEPTION
WHEN OTHERS THEN
IF SQLCODE != -942 THEN
RAISE;
END IF;
END;
END LOOP;
-- MVIEW
FOR REC IN (
SELECT mview_name FROM USER_MVIEWS
)
LOOP
BEGIN
EXECUTE IMMEDIATE 'DROP MATERIALIZED VIEW ' || REC.mview_name;
EXCEPTION
WHEN OTHERS THEN
IF SQLCODE != -942 THEN
RAISE;
END IF;
END;
END LOOP;
-- FUNCTION
FOR REC IN (
SELECT object_name FROM user_objects WHERE object_type = 'FUNCTION'
)
LOOP
BEGIN
EXECUTE IMMEDIATE 'DROP FUNCTION ' || REC.object_name;
EXCEPTION
WHEN OTHERS THEN
IF SQLCODE != -942 THEN
RAISE;
END IF;
END;
END LOOP;
-- PROCEDURE
FOR REC IN (
SELECT object_name FROM user_objects WHERE object_type = 'PROCEDURE'
)
LOOP
BEGIN
EXECUTE IMMEDIATE 'DROP PROCEDURE ' || REC.object_name;
EXCEPTION
WHEN OTHERS THEN
IF SQLCODE != -942 THEN
RAISE;
END IF;
END;
END LOOP;
-- DATABASE LINK
FOR REC IN (
SELECT object_name FROM user_objects WHERE object_type = 'DATABASE LINK'
)
LOOP
BEGIN
EXECUTE IMMEDIATE 'DROP DATABASE LINK ' || REC.object_name;
EXCEPTION
WHEN OTHERS THEN
IF SQLCODE != -942 THEN
RAISE;
END IF;
END;
END LOOP;
-- TYPE
FOR REC IN (
SELECT object_name FROM user_objects WHERE object_type = 'TYPE'
)
LOOP
BEGIN
EXECUTE IMMEDIATE 'DROP TYPE ' || REC.object_name || ' FORCE';
EXCEPTION
WHEN OTHERS THEN
IF SQLCODE != -942 THEN
RAISE;
END IF;
END;
END LOOP;
-- JOB
FOR REC IN (
SELECT object_name FROM user_objects WHERE object_type = 'JOB'
)
LOOP
dbms_scheduler.drop_job(REC.OBJECT_NAME);
END LOOP;
-- Drop SYNONYM
FOR REC IN (
select OBJECT_NAME from user_objects where object_type = 'SYNONYM'
)
LOOP
BEGIN
EXECUTE IMMEDIATE 'DROP SYNONYM ' || REC.OBJECT_NAME;
EXCEPTION
WHEN OTHERS THEN
IF SQLCODE != -942 THEN
RAISE;
END IF;
END;
END LOOP;
end;
2013年2月14日 星期四
Layout - BoxLayout
BoxLayout
BoxLayout1, 水平與垂直Box, X_AXIS, Y_AXIS
BoxLayout2, 自動推開元件: Glue, HorizontalGlue, VerticalGlue
BoxLayout3, 固定大小的分隔: HorizontalStrut, VerticalStrut
BoxLayout4, 有長跟寬的分隔: RigidArea
BoxLayout5, 有最小最大跟預設大小的RigidArea: Box.Filler
BoxLayout6, Box中在裝Box: HorizontalBox, VerticalBox
X_AXIS:从左到右水平布置组件。
Y_AXIS:从上到下垂直布置组件。
LINE_AXIS:根据容器的 ComponentOrientation 属性,按照文字在一行中的排列方式布置组件。如果容器的 ComponentOrientation 表示水平,则将组件水平放置,否则将它们垂直放置。对于水平方向,如果容器的 ComponentOrientation 表示从左到右,则组件从左到右放置,否则将它们从右到左放置。对于垂直方向,组件总是从上到下放置的。
PAGE_AXIS:根据容器的 ComponentOrientation 属性,按照文本行在一页中的排列方式布置组件。如果容器的 ComponentOrientation 表示水平,则将组件垂直放置,否则将它们水平放置。对于水平方向,如果容器的 ComponentOrientation 表示从左到右,则组件从左到右放置,否则将它们从右到左放置。对于垂直方向,组件总是从上向下放置的。
BoxLayout1, 水平與垂直Box, X_AXIS, Y_AXIS
import java.awt.Container;
import java.awt.GridLayout;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class TestBoxLayout1 {
public static void main(String[] args) {
JFrame frame = new JFrame("BoxLayout-1");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container cp = frame.getContentPane();
cp.setLayout(new GridLayout(0, 1));
JPanel panel = null;
panel = new JPanel();
panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
panel.add(new JButton("1"));
panel.add(new JButton("2"));
panel.add(new JButton("3"));
cp.add(panel);
panel = new JPanel();
panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
panel.add(new JButton("4"));
panel.add(new JButton("5"));
panel.add(new JButton("6"));
cp.add(panel);
frame.setVisible(true);
frame.pack();
}
}
BoxLayout2, 自動推開元件: Glue, HorizontalGlue, VerticalGlue
import java.awt.Color;
import java.awt.Container;
import java.awt.GridLayout;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class TestBoxLayout2 {
public static void main(String[] args) {
JFrame frame = new JFrame("BoxLayout-2");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container cp = frame.getContentPane();
cp.setLayout(new GridLayout(0, 1));
JPanel panel = null;
// glue在垂列與水平的boxLayout中有作用
panel = new JPanel();
panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
panel.add(new JButton("1"));
panel.add(Box.createGlue());
panel.add(new JButton("2"));
panel.add(new JButton("3"));
cp.add(panel);
panel = new JPanel();
panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
panel.add(new JButton("1"));
panel.add(Box.createGlue());
panel.add(new JButton("2"));
panel.add(new JButton("3"));
cp.add(panel);
// 水平的glue只在水平的BoxLayout中有作用
panel = new JPanel();
panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
panel.add(new JButton("1"));
panel.add(Box.createHorizontalGlue());
panel.add(new JButton("2"));
panel.add(new JButton("3"));
cp.add(panel);
// 水平的glue在垂列的box中沒有作用
panel = new JPanel();
panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
panel.add(new JButton("1"));
panel.add(Box.createHorizontalGlue());
panel.add(new JButton("2"));
panel.add(new JButton("3"));
cp.add(panel);
frame.setVisible(true);
frame.pack();
}
}
BoxLayout3, 固定大小的分隔: HorizontalStrut, VerticalStrut
import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.GridLayout;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class TestBoxLayout3 {
public static void main(String[] args) {
JFrame frame = new JFrame("BoxLayout-3");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container cp = frame.getContentPane();
cp.setLayout(new GridLayout(0, 1));
JPanel panel = null;
panel = new JPanel();
panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
panel.add(new JButton("1"));
panel.add(Box.createHorizontalGlue());
panel.add(new JButton("2"));
panel.add(new JButton("3"));
cp.add(panel);
// Strut可以固定分隔的大小
panel = new JPanel();
panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
panel.add(new JButton("1"));
panel.add(Box.createHorizontalStrut(50));
panel.add(new JButton("2"));
panel.add(new JButton("3"));
cp.add(panel);
frame.setVisible(true);
frame.pack();
}
}
BoxLayout4, 有長跟寬的分隔: RigidArea
import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.GridLayout;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class TestBoxLayout4 {
public static void main(String[] args) {
JFrame frame = new JFrame("BoxLayout-4");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container cp = frame.getContentPane();
cp.setLayout(new GridLayout(0, 1));
JPanel panel = null;
// RigidArea就像是有寬跟高的strut
// 設置比較大的值 會讓排版的大小也變得更大
panel = new JPanel();
panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
panel.add(new JButton("1"));
panel.add(Box.createRigidArea(new Dimension(100, 50)));
panel.add(new JButton("2"));
panel.add(new JButton("3"));
cp.add(panel);
panel = new JPanel();
panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
panel.add(new JButton("1"));
panel.add(Box.createRigidArea(new Dimension(100, 50)));
panel.add(new JButton("2"));
panel.add(new JButton("3"));
cp.add(panel);
frame.setVisible(true);
frame.pack();
}
}
BoxLayout5, 有最小最大跟預設大小的RigidArea: Box.Filler
import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.GridLayout;
import javax.swing.Box;
import javax.swing.Box.Filler;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class TestBoxLayout5 {
public static void main(String[] args) {
JFrame frame = new JFrame("BoxLayout-5");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container cp = frame.getContentPane();
cp.setLayout(new GridLayout(0, 1));
JPanel panel = null;
//Filler 就像是可變動大小的Strut
panel = new JPanel();
panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
panel.add(new JButton("1"));
Dimension min = new Dimension(50, 50);
Dimension max = new Dimension(150,150);
Dimension preferred = new Dimension(100, 100);
Filler filler = new Box.Filler(min, preferred, max);
panel.add(filler);
panel.add(new JButton("2"));
panel.add(new JButton("3"));
cp.add(panel);
frame.setVisible(true);
frame.pack();
}
}
BoxLayout6, Box中在裝Box: HorizontalBox, VerticalBox
import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.GridLayout;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class TestBoxLayout6 {
public static void main(String[] args) {
JFrame frame = new JFrame("BoxLayout-6");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container cp = frame.getContentPane();
cp.setLayout(new GridLayout(0, 1));
JPanel panel = null;
// Box的功能 其實可以直接其他layout搭配Box來用!!!
panel = new JPanel();
panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
panel.add(new JButton("1"));
Box box = Box.createVerticalBox();
box.add(new JButton("4"));
box.add(new JButton("5"));
box.add(new JButton("6"));
panel.add(box);
panel.add(new JButton("2"));
box = Box.createVerticalBox();
box.add(new JButton("7"));
box.add(new JButton("8"));
box.add(new JButton("9"));
panel.add(box);
panel.add(new JButton("3"));
cp.add(panel);
frame.setVisible(true);
frame.pack();
}
}
Layout - BorderLayout, FlowLayout, GridLayout
BorderLayout - Example
除了常見的東西南北中發白之外 再加上Hgap與VGap兩個屬性
import java.awt.BorderLayout;
import java.awt.Container;
import javax.swing.JButton;
import javax.swing.JFrame;
public class TestBorderLayout {
public static void main(String[] args) {
JFrame frame = new JFrame("BorderLayout");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container cp = frame.getContentPane();
BorderLayout layout = new BorderLayout();
layout.setHgap(100);
layout.setVgap(30);
cp.setLayout(layout);
JButton north = new JButton("North");
JButton south = new JButton("South");
JButton east = new JButton("East");
JButton west = new JButton("West");
JButton center = new JButton("Center");
cp.add(north, BorderLayout.NORTH);
cp.add(south, BorderLayout.SOUTH);
cp.add(east, BorderLayout.EAST);
cp.add(west, BorderLayout.WEST);
cp.add(center, BorderLayout.CENTER);
frame.setVisible(true);
frame.pack();
}
}
FlowLayout - Example
預設值除了Hgap與VGrap外多了一個Alignment
import java.awt.Color;
import java.awt.Container;
import java.awt.FlowLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
public class TestFlowLayout {
public static void main(String[] args) {
JFrame frame = new JFrame("FlowLayout");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container cp = frame.getContentPane();
FlowLayout layout = new FlowLayout(FlowLayout.CENTER, 10, 10);
// DEFAULT is (CENTER, 5, 5)
cp.setLayout(layout);
JButton btn[] = new JButton[10];
for(int i = 0 ; i < btn.length; i++){
btn[i] = createBtn(i);
cp.add(btn[i]);
}
frame.setVisible(true);
frame.pack();
}
private static JButton createBtn(int i) {
JButton btn = new JButton();
Color bg = new Color(i*256/10,i*256/10,i*256/10);
btn.setText(""+(i*256/10));
btn.setForeground(bg);
return btn;
}
}
![]() |
| 靠左,中,右對齊 |
GridLayout
不得不說的事情是當我們放元件進去的時候是無法指定他放在grid的什麼位置的
因為這個layout的排版方式就是將parent裡面的所有元件拿來依照指定的gird size來排位置
import java.awt.Container;
import java.awt.GridLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
public class TestGridLayout {
public static void main(String[] args) {
JFrame frame = new JFrame("FlowLayout");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container cp = frame.getContentPane();
// DEFAULT is (1, 0, 0, 0);
GridLayout layout = new GridLayout(5, 5, 10, 10);
cp.setLayout(layout);
for(int i = 0 ; i < 25 ; i++){
if(i%2 == 0){
cp.add(new JButton(""+i));
}else{
cp.add(new JLabel());
}
}
frame.setVisible(true);
frame.pack();
}
}
2013年1月24日 星期四
MySQL指令 紀錄
mysqladmin -u root password 'password'
mysqladmin -u root -p password 'newPassord'
mysql -u root -p
mysqladmin -u root -p password 'newPassord'
mysql -u root -p
2013年1月6日 星期日
~/.profile 沒有作用
昨天發現寫在.profile的一些export沒有作用,後來發現原來是安裝SyncGood之後它自動幫我建了一個~/.bash_profile所以導致我的~/.profile沒作用!!
查了一下執行/etc/profile, ~/.bash_profile, ~/.bash_login, ~/.profile, ~/.bashrc等 的執行順序
1. /etc/profile
以下三個會先遇到先執行 之後的就跳過
2.1. ~/.bash_profile
2.2. ~/.bash_login
2.3. ~/.profile
登出的時候會執行
~/.bash_logout
2013年1月3日 星期四
httpd apache2
Apache目錄: /etc/apache2
確定 userdir_module 沒有被注解
LoadModule userdir_module libexec/apache2/mod_userdir.so
把 /etc/apache2/users/Guest.conf 複製一份成 /etc/apache2/users/userName.conf
將內容修改為
<Directory "/Users/userName/Sites/">
Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>
指令 httpd -k [start|stop|restart]
開啟 httpd
瀏覽器 http://localhost/~userName
確定 userdir_module 沒有被注解
LoadModule userdir_module libexec/apache2/mod_userdir.so
把 /etc/apache2/users/Guest.conf 複製一份成 /etc/apache2/users/userName.conf
將內容修改為
<Directory "/Users/userName/Sites/">
Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>
指令 httpd -k [start|stop|restart]
開啟 httpd
瀏覽器 http://localhost/~userName
2012年12月16日 星期日
Maven 指令
mvn dependency:sources
下載 source code
mvn help:describe -Dplugin=help -Dgoal=describe -Ddetail
pmd
mvn pmd:pmd -DtargetJdk=1.6
下載 source code
mvn help:describe -Dplugin=help -Dgoal=describe -Ddetail
pmd
mvn pmd:pmd -DtargetJdk=1.6
訂閱:
文章 (Atom)








