Thursday, July 30, 2009

List of metacharacters in regular expression(regexp)

Most basic regular expression consists of list of metacharacters. These metacharacters have a special meaning in regular expression. In this post I will show you the list of eleven metacharacters exist in most regular expression and their meaning.

1)Dot .: Dot matches any single character except a newline. For example, if it is said a.b then it can indicates aab or axb or avb or a%b etc.

But remember that if you use dot (.) within square bracket then it becomes literal. If we use [a.b] then it describes only "a" or "." or "b".

2)Bracket[]: Bracket matches a set of possible character contains inside it. For example if we write [abcde] then it describes "a" or "b" or "c" or "d" or "e". Within bracket we can also specify a range of characters using dash (-). Suppose, [a-z] specifies a range which matches any lowercase letter from "a" to "z". We can use it in various ways. Like [mp-s] indicates "m" or "p" or "q" or "r" or "s", also we can indicate same expression by, [mpq-s].

But remember that if dash(-) is specified as last character inside bracket or specified after backslash then it becomes literals. Suppose [mnq-] expresses "m" or "n" or "q" or "-". [mp\-s] denotes "m" or "p" or "-" or "s".

3)Caret within bracket [^]: Caret within bracket just do negation. If we specify caret inside bracket then it matches all characters that is not inside bracket. For example if we write [^bcd] then it matches any characters other than "b","c","d". If we write [^m-p] then it matches any single character that is not matches any lowercase character between m to p., i.e not m, n, o, p.

4)Caret ^: Caret (^) means it matches beginning of a line or beginning of a string.

5)Dollar sign $: Dollar sign ($) means it matches ending position of a line or ending position of a string.

6)Plus sign +: Plus sign (+) matches the preceding pattern element one or more times. For example if we write, xy+z then it matches xyz, xyyz, xyyyz etc.

7)question mark ?: Question mark (?) matches the preceding pattern element zero or one time.
For example if we write xy?z then it matches only xz and xyz.

8)Asterisk sign *: Asterisk (*) matches the preceding pattern element zero or more times.
For example if we write xy*z then it matches xz, xyz, xyyz etc.

9)vertical bar or pipe symbol |: It matches the expression before vertical bar or matches the expression after vertical bar. If we write a|b then it matches either "a" or "b".

10){M,N}: It expresses the minimum M and the maximum N match count of the preceding character. For example if we write a{M,N} "a" matches minimum M times and maximum N times.

11)\b: Matches a word boundary. For example, \b upon word "test" matches st, t, est etc.

12)\w: Matches an alphanumeric character, including "_". For example, \w matches [a-zA-Z0-9_].

13)\W: Matches a non-alphanumeric character, excluding "_". So, \W matches [^a-zA-Z0-9_].

14)\s: Matches a whitespace character (space, tab, newline, form feed). So, \s matches space, tab, newline, form feed.

15)\S: Matches anything except a whitespace.

16)\d: Matches a digit. We can also donate as [0-9].

19)\D: Matches a non-digit. We can also donate as [^0-9].

Related Documents
http://arjudba.blogspot.com/2009/07/what-is-regular-expression-or-regex-or.html
http://arjudba.blogspot.com/2009/06/how-to-add-word-or-letter-at-end-of.html
http://arjudba.blogspot.com/2009/06/how-to-add-line-to-first-in-file-using.html

What is regular expression or regex or regexp

Regular expression or in other words regex or regexp is a pattern that describes particular characters or words or patterns of characters. Regular expressions provide very flexible way to to express a set of characters that we are interest of.

You may have questions about why regular expression comes? What is the use of it? To answer it, let's look a simple example below.

You have a written large piece of code in your development environment where is used upper version of php and the code contains following words.
$stmt->bindParam(':userName', $userName);
$stmt->bindParam(':password', $password);
$stmt->bindParam(':firstName', $firstName);
$stmt->bindParam(':lastName', $lastName);
$stmt->bindParam(':companyName', $companyName);

There exists this types of statements many times and many places in your code. Suppose you have 40,000 lines of code and out of 40,000 lines you have this type of statements in 5,000 places. Now in your production you see php version there does not support bindparam function. So what you need to do? You need to search all 40,000 lines and find the 5,000 places where bindparam function exists and then replace the function with suitable function that is supported by that version as well as corresponding syntax of that function.

In this example we are needed to change all $stmt->bindParam by mysql_real_escape_string as well as we don't need bind variable and their quote, for example we exactly need to look as
mysql_real_escape_string( $userName);
mysql_real_escape_string( $password);
mysql_real_escape_string( $firstName);
mysql_real_escape_string( $lastName);
mysql_real_escape_string( $companyName);


In this scenario with using regular expression we can save a lots of time just using a single expression wise search and replace command. If you just do search
$stmt-<bindParam(':any_character_here',
and replace them by
mysql_real_escape_string(
then our goal will be achieved. Regular expression does the trick, search for pattern
$stmt-<bindParam('.*',
and then replace them by,
mysql_real_escape_string(

where .* combination denotes regular expression.
-Dot(.) indicates matches any character except a newline.
-* indicates matches the preceding pattern element zero or more times.


So if there is such pattern found like
first comes $stmt-<bindParam('
and finish by ', which is followed by any combination of characters that to be replaced by mysql_real_escape_string(

We see here one command will do all 5,000 searches and replaces instead of searching/typing those.

We also need regular expression to express certain types of patterns while writing something. Like someone wrote , "I love grey|gray color". Here | is regular expression which indicates any of grey or gray.

This is all about regular expression, their usage. In subsequent post I will go more with regular expressions.

Related Documents

How to add a word or letter at the end of each line in shell script


How to add a line to the first in a file using shell script

Tuesday, July 28, 2009

A different idea of advertising your site

Do you live in a developing country like Romania, Bangladesh, Pakistan, India or China? Well, if you also live in a developed country like United States or Canada you might also
choose to live or buy space in other country. You might not have the ability to do so as you cannot afford it. But in the site http://www.buyaplaceonearth.comthere brings an opportunity to buy space of
another place wherever you live in.

The site provides you the possibility to become the owner of any place on earth, and post there a picture/logo so that whole internet users can see it. You can buy any part of your own country, part of any ocean, whole continent or you can choose other continent different that you live. Imagine you have space in an ocean where no man ever reach there.

In the 3d pixel advertising the earth is full 3D and interactive, you can zoom in/out and spin it whatever you prefer. That is you can see in detail level before buying your place on this earth.

Now let’s analyze some advantages of having this space of the earth.

Advantages

1) 3D Format! – something new on web, the technology is at the beginning, but it has great potential, I personally found another 3D Globe just on Discovery Website. I repeat, this is the first 3D Advertising webpage!

2) It intrigues the visitor’s curiosity way better than a plane pixel advertising website where the positioning doesn’t mean anything! Also it more efficient than a banner on any other website because there is no information/content that can distract the visitor’s attention from the ads.

3) Extremely low costs, considering that the images will remain there for at least 5 years, and the payment is made only once (not each month nor year) .It is a future investment for those who want to make their company better known, or for those who just want to bring more visitors to their website. Note that all visitors brought to your website are UNIQUE.

4) It can work as a web directory but in a different and new format.

5) In stead of traditional advertising, you can have now a very good look and feel advertisement.

6) You can also focus a particular geography by buying space for that geography as well as you can focus entire world.

Related Documents

List of Available Advertising Network Companies

Sunday, July 26, 2009

How to retrieve checkbox value from mysql database

In this post I will show you how to retrieve checkbox value from database. As in the database in one field there resides multiple checkbox value so we need to be cautious while displaying checkbox data specially which box to be checked and which not.

Let's assume that field values for method #1 that is described inside http://arjudba.blogspot.com/2009/07/entering-mutiple-values-with-checkbox.html

We assume that checkbox field data are inserted into the database using comma separated values.

BY manually we are doing here for testing purpose.

mysql> delete from checkbox;
Query OK, 2 rows affected (0.00 sec)

mysql> insert into checkbox values('meat,vegetable,fastfood');
Query OK, 1 row affected (0.00 sec)

mysql> select * from checkbox;
+-------------------------+
| foods |
+-------------------------+
| meat,vegetable,fastfood |
+-------------------------+
1 row in set (0.00 sec)

Now following is the php code that is used to display for checkbox. Specially look at the condition,

if (in_array($food,$foods_ex)){
echo "<td>";
echo "<input type=\"checkbox\" name=\"food_cat[]\" value=$food checked>$food</input>";
echo "</td>";
}
else{
echo "<td>";
echo "<input type=\"checkbox\" name=\"food_cat[]\" value=$food>$food</input>";
echo "</td>";
}


<?
include('include/db.php');

$query="select foods from checkbox limit 1";

$result = mysql_query($query);
if(mysql_num_rows($result)>0){
$row = mysql_fetch_array($result);
extract($row);
}
mysql_close();

?>

<html>
<body>
<form method="post">
<table width="50%">
<th>What is your favorite food?</th>
<tr>
<?
$array_food=array('fish','meat','vegetable','fastfood','soup');
$foods_ex=explode(',',$foods);
//print_r ($foods_ex);
foreach($array_food as $food){
if (in_array($food,$foods_ex)){
echo "<td>";
echo "<input type=\"checkbox\" name=\"food_cat[]\" value=$food checked>$food</input>";
echo "</td>";
}
else{
echo "<td>";
echo "<input type=\"checkbox\" name=\"food_cat[]\" value=$food>$food</input>";
echo "</td>";
}
}

?>

</tr>
<tr>

<td colspan="6" style="padding-left:30em">
<input type="submit" name="submit" value="save">
</td>
</table>
</form>
</body>
</html>

Whenever you execute above php code output like below will be displayed in the browser.










What is your favorite food?
fishmeatvegetablefastfoodsoup





Related Documents
http://arjudba.blogspot.com/2009/07/entering-mutiple-values-with-checkbox.html

Entering multiple values with checkbox into mysql

In this post I will discuss how I can pass multiple values of checkbox into mysql database. If we try to insert checkbox data in normal way then we will see only one value of it is inserted. Also, there is exactly one field to hold multiple checkboxes data unless you want to insert multiple records into database. Now the question is how to insert multiple values into one field for checkbox data.

There are several ways by which we can insert multiple checkbox data into mysql database. In the following section it is discussed.

Way 01 Using Implode function
1)Prepare table to hold multiple checkbox data.
Declare as varchar of the field that will hold checkbox data. Note that your database field must be greater than the summation of all checkbox values length so that it can hold multiple checkbox value.

mysql> create table checkbox(foods varchar(60));
Query OK, 0 rows affected (0.14 sec)

mysql> select * from checkbox;
Empty set (0.00 sec)

2)Note that to insert multiple checkbox values, all checkbox html name must be declared as array. Like in this example it is declared as,
-<input type="checkbox" name="all_food[]" value=$food>$food</input>

And while inserting value into database we need to append a character like comma(,) after each checkbox value so that we can distinguish multiple checkboxes data. This is done by implode function as in described in the example.

<?
if(isset($_POST['submit'])) {
include('include/db.php');
$arrays = implode(",",$_POST['all_food']);
$query="insert into checkbox values('".$arrays."')";
//echo $query;
mysql_query($query) or die ('Error inserting values into database, please go back and try again');
mysql_close();
}
?>

<html>
<body>
<form method="post">
<table width="50%">
<th>What is your favorite food?</th>
<tr>
<?
$array_food=array('fish','meat','vegetable','fastfood','soup');
foreach($array_food as $food){
echo "<td>";
echo "<input type=\"checkbox\" name=\"all_food[]\" id=\"all_food\" value=$food>$food</input>";
echo "</td>";
}

?>

</tr>
<tr>

<td colspan="6" style="padding-left:30em">
<input type="submit" name="submit" value="save">
</td>
</table>
</form>
</body>
</html>

If we run above php code and after check different checkboxes multiple values are inserted into database as below.

mysql> select * from checkbox;
+--------------------------+
| foods |
+--------------------------+
| meat,vegetable,fast,soup |
| meat,vegetable,fastfood |
| fish,meat,fastfood |
+--------------------------+
3 rows in set (0.00 sec)

Way 02: Inserting data using serialize function

<?
if(isset($_POST['submit'])) {
include('include/db.php');
$arrays = serialize($_POST['all_food']);
$query="insert into checkbox values('".$arrays."')";
//echo $query;
mysql_query($query) or die (mysql_error());
mysql_close();
}
?>

<html>
<body>
<form method="post">
<table width="50%">
<th>What is your favorite food?</th>
<tr>
<?
$array_food=array('fish','meat','vegetable','fastfood','soup');
foreach($array_food as $food){
echo "<td>";
echo "<input type=\"checkbox\" name=\"all_food[]\" value=$food>$food</input>";
echo "</td>";
}

?>

</tr>
<tr>

<td colspan="6" style="padding-left:30em">
<input type="submit" name="submit" value="save">
</td>
</table>
</form>
</body>
</html>


From the database it will display,

mysql> select * from checkbox;
+--------------------------------------------------------------+
| foods |
+--------------------------------------------------------------+
| a:3:{i:0;s:4:"meat";i:1;s:9:"vegetable";i:2;s:8:"fastfood";} |
| a:3:{i:0;s:4:"fish";i:1;s:4:"meat";i:2;s:8:"fastfood";} |
| a:2:{i:0;s:4:"meat";i:1;s:4:"soup";} |
+--------------------------------------------------------------+
3 rows in set (0.00 sec)


Here,
- a:3 indicates how many checkbox values are there.
- i:0 indicates it is the first checkbox value inserted. i:1 means it is in the serial second to be inserted data into mysql database and so on.
- s:4 indicates how many letters in the value. s:4 means four letters, s:8 means eight letters.

Related Documents
Datatypes in Php
Integer and floating point number in Php
Variables in PHP

Tuesday, July 21, 2009

Disable Skype from Using, Opening or Listening on Port 80 and 443

If you have running skype in your system and you now try to install web server or a program that need to use HTTP port 80 or HTTPS port 443, then there possibly an error message saying that the port 80 or 443 has been in used or occupied by another application. Though you don't have currently installed any web server like Apache or IIS (Microsoft Internet Information Service).

So you need to investigate which program is using/opening/listening on port 80 or 443. In the post, How to check or identify which process is listening to port 80 in windows it is clearly discussed who you can know which process listening on which port. So you can know the process name from that post.

Now our concern is about skype. Skype allows users to use port 80 and 443 as an alternatives for incoming connections. Skype uses port 80 and 443 to allow Skype behind firewall to connect to peer or accept incoming connection from peers.

Only one program can open/use/listen one port at a time. So if skype uses port 80 other program will not be able to use it. Skype uses port 80 and port 443 (for SSL HTTP connection) and thus prevent other applications which require such port from working properly. So to make important program to work like web server we need to disable skype to use port 80 and port 443. Also, leaving the port 80 and 443 opens and listening also has security risk where the port can be scanned by malicious virus or hacker to launch attack or infection.

If you want to use skype and also web sever then you must turn off and disable Skype usage of and listening on port 80 and port 443. following is the steps to do this.

1) Open the Skype window.

2) Click on Tools menu.

3) Select Options.

4) Click on Advanced tab.

5) Go to Connection sub-tab.

6) Untick or uncheck the check box for "Use port 80 and 443 as an alternatives for incoming connections option."

7) Click on Save button and then restart Skype to make the change effective.

Related Documents

How to include a php file inside smarty template

Well, many one of you heard about smarty template. In simple way we can say, Smarty template makes your PHP scripts independent of the layout.

While working with smarty template you may need to run a php code from the smarty template. Smarty always give the flexibility to do display code simply as a text as well as to execute php code.

Let's assume we have just installed smarty.
-You will see under Smarty>libs folder the main smarty class php file named Smarty.class.php and we need to make instance of Smarty class to use it.

-You can see sample code under Smarty>demo.

-And the template resides under Smarty>demo>templates.

Now we will execute php script named welcome.php from template named welcome.tpl

My welcome.php contains,
<?php
echo "Welcome to arjudba world.";
?>


and is saved under Smarty>demo.

My welcome.tpl contains,
{include_php file="welcome.php"}

and is saved under Smarty>demo>temaplates. Note that we can give full path here. Like {include file="include($_SERVER['DOCUMENT_ROOT'].'/includes/welcome.php');"}

Now from a php file we need to call the template file welcome.tpl and eventually template file will call welcome.php file. Let's name this php file as Smarty/display.php which contains,

<?php

require '../libs/Smarty.class.php';

$smarty = new Smarty;

$smarty->compile_check = true;
$smarty->debugging = true;
$smarty->display('welcome.tpl');

?>



Now in browser if you run for example on machine http://localhost/smarty/demo/display.php it will display,
Welcome to arjudba world.

And you are done. From welcome.tpl you ran welcome.php script.

I have shown a simple way above about how to run php script from template. There are other ways to do the job. Like in the template file writing as,

{php}
include("welcome.php");
{/php}


Related Documents
Datatypes in Php
Integer and floating point number in Php
Variables in PHP
Magic constants in php
Boolean datatype in Php

Monday, July 20, 2009

How to check or identify which process is listening to port 80 in windows

From yesterday, on my computer I could not start my apache service. From the XAMPP Control Panel Application whenever I start Apache it fails to start. I reinstalled apache several time but it could not help . In fact after installing Apache HTTPD web server or Microsoft IIS Internet Information Services web server, or any other application software or service and daemon that requires to open and listen to port 80 (HTTP) or port 443 (HTTPS SSL) it fails. So I consider myself to investigate about the program that is using port 80 or 443.

I am sure that a program is using port 80 or port 443 and restrict apache to use these port as I get following after installing Apache web server using XAMPP.

(OS 10052) Only one usage of each socket address (protocol/network address/port) is normally permitted. : make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down


So, I need to identify the program which is listening to port 80 and kill that process or at least restrict that process to listen to port 80.

To following steps will help you to find the culprit one.

1)Open command prompt. You can do it by clicking your start menu, then select Run, type cmd in the Run box and hit enter.

2)I expect you will see command prompt here unless you have viruses in your computer that restrict to show. In the command prompt type,

>netstat -o -n -a | findstr 0.0:80
in order to determine the process ID which is using port 80.

or type,
>netstat -o -n -a | findstr 0.0:443
in order to determine the process ID which is listening to port 443.

or type,
>netstat -aon
in order to list all connection that is listening, established, starting, closing and all other states. As netstat -aon will list all connections so from that you need to manually search for line 0.0.0.0:80 or 0.0.0.0:443 to determine the process ID.

3)Determine the process ID which is listening to port 80 or 443.
A typical output from the above commands are,
E:\Documents and Settings\Arju>netstat -o -n -a | findstr 0.0:80
TCP 0.0.0.0:80 0.0.0.0:0 LISTENING 4712

E:\Documents and Settings\Arju>netstat -o -n -a | findstr 0.0:443
TCP 0.0.0.0:443 0.0.0.0:0 LISTENING 4712
UDP 0.0.0.0:443 *:* 316

E:\Documents and Settings\Arju>netstat -aon

Active Connections

Proto Local Address Foreign Address State PID
TCP 0.0.0.0:80 0.0.0.0:0 LISTENING 4712
TCP 0.0.0.0:135 0.0.0.0:0 LISTENING 1324
TCP 0.0.0.0:443 0.0.0.0:0 LISTENING 4712
TCP 0.0.0.0:3306 0.0.0.0:0 LISTENING 1920
TCP 0.0.0.0:5101 0.0.0.0:0 LISTENING 7636
TCP 0.0.0.0:17536 0.0.0.0:0 LISTENING 316
TCP 10.65.49.113:1175 118.160.238.122:80 ESTABLISHED 316
TCP 10.65.49.113:1451 209.85.137.125:5222 ESTABLISHED 1588
TCP 10.65.49.113:1561 66.102.9.83:80 CLOSE_WAIT 3436
TCP 10.65.49.113:1623 96.17.159.66:80 CLOSE_WAIT 1964
TCP 10.65.49.113:2659 216.10.192.112:80 CLOSE_WAIT 5164
TCP 10.65.49.113:2782 216.10.192.112:80 CLOSE_WAIT 3692
TCP 10.65.49.113:3084 74.125.87.83:80 ESTABLISHED 2736
TCP 10.65.49.113:3179 74.125.87.191:80 ESTABLISHED 2736
TCP 10.65.49.113:3180 74.125.87.83:80 ESTABLISHED 2736
TCP 10.65.49.113:3185 74.125.87.101:443 ESTABLISHED 5164
TCP 10.65.49.113:3187 74.125.87.147:80 ESTABLISHED 5164
TCP 10.65.49.113:3850 68.180.217.28:5050 ESTABLISHED 7636
TCP 10.65.49.113:3881 68.142.233.181:80 ESTABLISHED 7636
TCP 10.65.49.113:4837 207.46.125.86:1863 ESTABLISHED 320
TCP 127.0.0.1:1247 0.0.0.0:0 LISTENING 3692
TCP 127.0.0.1:1557 0.0.0.0:0 LISTENING 6172
TCP 127.0.0.1:1557 127.0.0.1:1558 ESTABLISHED 6172
TCP 127.0.0.1:1558 127.0.0.1:1557 ESTABLISHED 7928
TCP 127.0.0.1:1672 0.0.0.0:0 LISTENING 1532
TCP 127.0.0.1:1727 127.0.0.1:1728 ESTABLISHED 7636
TCP 127.0.0.1:1728 127.0.0.1:1727 ESTABLISHED 7636
TCP 127.0.0.1:1990 127.0.0.1:1991 ESTABLISHED 5164
TCP 127.0.0.1:1991 127.0.0.1:1990 ESTABLISHED 5164
TCP 127.0.0.1:1993 127.0.0.1:1994 ESTABLISHED 5164
TCP 127.0.0.1:1994 127.0.0.1:1993 ESTABLISHED 5164
UDP 0.0.0.0:443 *:* 316
UDP 0.0.0.0:17536 *:* 316
UDP 10.65.49.113:123 *:* 1364
UDP 10.65.49.113:1900 *:* 1500
UDP 127.0.0.1:123 *:* 1364
UDP 127.0.0.1:1025 *:* 1924
UDP 127.0.0.1:1171 *:* 316
UDP 127.0.0.1:1716 *:* 320
UDP 127.0.0.1:1730 *:* 7636
UDP 127.0.0.1:1900 *:* 1500
UDP 127.0.0.1:2993 *:* 1588
UDP 127.0.0.1:9877 *:* 1924
UDP 127.0.0.1:9977 *:* 1924
UDP 127.0.0.1:62976 *:* 1924

From the above output we see process ID 4712 is the culprit one which is listening to port 80 and 443 and thus restrict web server to use them.

4)In this step find the process which has the Process ID 4712. You can simply follow http://arjudba.blogspot.com/2009/07/how-to-know-process-id-or-pid-on.html and bring task manager to display that process ID. From task manager Image Name determine the process name.

So now you can kill that process or still if you want to run that process first run you web server/apache and then run that program. In this way apache first will listen to port 80 and that program will not be able to use as it starts after web server.

Related Documents

How to know process ID or PID on windows

Process Identifier or Process ID or PID is the unique ID of a process running on the system. With PID we can uniquely identify a process and can know about their characteristics.

On unix based system like linux, solaris, HP-UX with "ps" command we can easily identify each type of process and their PID. We can also grep the output for filtering. But for Windows operating system such as Windows 95, Windows 98, Windows 2000, Windows XP, Windows Vista, Windows Server 2003, Windows Server 2008 and Windows 7 there is no such utility or command.

In windows through GUI we can still see the process ID or PID of a process. This is sometime very essential to track a culprit process. It can be seen from Task Manager. To get Task Manager right click on empty area in the task bar and then you can select Task Manger. You can also get Task Manager window by clicking CTRL+ALT+DEL.

After opening task manager you will see there is no process ID or PID there by default. But you can see Processes tab there. Whenever you click on processes tab, process information is shown. By default option is Image Name(Process Name), User Name(the user under whom process is running), CPU(percentage of CPU usage) and Mem Usage(Total how many KB is allocated to the process).

To get Process ID,
- Click Processes tab.
- Click on View menu, then click on Select Columns.
- In the "Select Columns" or "Select Process Page Columns" dialog, check the checkbox for PID (Process Identifier), and click OK.


You will see PID is shown and you can easily track each process identifier.

Related Documents

Friday, July 17, 2009

CSS margin with example.

To understand margin let's start a general example and see how it display in the browser. Copy the following code and see from browser,

<html>
<body>
In this blog http://arjudba.blogspot.com you will
see there is some space (though a very little amount)
all around. But there is no space whenever you
will disply this html code inside your browser.
<blockquote>

But there will be some spaces all around this
blockquote. Both left, right, top, bottom side.

</blockquote>
You are recommended to join http://arju-on-it.com/forum
and discuss your problems there
</body>
</html>


If you run above html code, you will see all around of blockquote text there is space. But don't have control how much space will be all around. In CSS, this space is called "margins" and margins are controlled by four properties, margin-left, margin-right, margin-top and margin-bottom. We can minimize space around blockquote by following css code,

blockquote {
margin-top: 1em;
margin-right: 0em;
margin-bottom: 1em;
margin-left: 0em;
}

We can shorthand margin property by setting all margin properties using,

blockquote{
margin: 1em 0em 1em 0em;
}

The first part 1em is for margin-top and then it goes clockwise, second part is margin-right, then margin-bottom and then margin-left.

Let's assign some background colour all around blockquote. We can do this simply by background. Like,

blockquote{
margin: 1em 0em 1em 0em;
background: #AAA;
}

We will see that the background color barely covers the quoted text. But the margin area is not affected. However if we want that background color will be there will some amount of space around quote text(element) then we have to use another property of CSS called padding.

With usage of padding css code will look like,

blockquote{
margin: 1em 0em 1em 0em;
background: #AAA;
padding:.5em .5em .5em .5em;
}

Similar to margin padding can be padding-top, padding-right, padding-bottom, padding-left.

So, our final code will look like,

<html>
<style type="text/css">
blockquote{
margin: 1em 0em 1em 0em;
background: #AAA;
padding:.5em .5em .5em .5em;
}
</style>
<body>
In this blog http://arjudba.blogspot.com you will
see there is some space (though a very little amount)
all around. But there is no space whenever you
will disply this html code inside your browser.
<blockquote>
But there will be some spaces all around this
blockquote. Both left, right, top, bottom side.
</blockquote>
You are recommended to join http://arju-on-it.com/forum
and discuss your problems there
</body>
</html>

Final output is in,




Wednesday, July 15, 2009

Exception in thread "main" java.lang.NoClassDefFoundError

For newbie, this problem is almost common in java. While compile java using javac it was successful. But whenever you execute the compiled file it fails with "Exception in thread "main" java.lang.NoClassDefFoundError". as below.

E:\Documents and Settings\Arju\Desktop\Rotimi New\Java>java Palindrome.class
Exception in thread "main" java.lang.NoClassDefFoundError: Palindrome/class
Caused by: java.lang.ClassNotFoundException: Palindrome.class
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
Could not find the main class: Palindrome.class. Program will exit.

The solution is add -classpath and a dot (.) which means, that it will search for classes bytecode in the current directory. Like below.
E:\Documents and Settings\Arju\Desktop\Rotimi New\Java>java -classpath . Palindrome
Enter number
345
Number:
345
After reversing the number:
543
Number is not palindrome!

Also note that, while executing if you add .class extension then similar error will throw. So while executing simply write,
E:\Documents and Settings\Arju\Desktop\Rotimi New\Java>java Palindrome
Enter number
3
Number:
3
After reversing the number:
3
Number is palindrome!

And adding .class will throw exception as below.
E:\Documents and Settings\Arju\Desktop\Rotimi New\Java>java Palindrome.class
Exception in thread "main" java.lang.NoClassDefFoundError: Palindrome/class
Caused by: java.lang.ClassNotFoundException: Palindrome.class
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
Could not find the main class: Palindrome.class. Program will exit.

Test speed to find a reliable hosting provider

There are many sites over the internet that make speed tests but most of them work on the same principle:
1) visit a web site
2) select a location with which you'll be making the speed test
3) start the test and check out the results

OR the more advanced option is to
1) visit a website
2) automaticall load in your page a Flash script
3) start the script which will then download and sometimes upload a file from/to a certain destination

While this approach is generally good enough it is completely useless when you need to check the speed between your computer and any website in the world.
"Why would I want to do that?" you may ask yourself.

Well, here's one of the reasons: you want to find a reliable hosting provider and the provider you just found advertise they have fast Internet connectivity. This may be true but what about if they host the site in US and your target audience is in Australia?

If that's the case use this http://tools.geek-tools.org/en/speedtest speed test tool, it is not yet perfect but it may help you make some real life tests on with different sites hosted by the same provider.

Related Documents

Monday, July 13, 2009

CSS Tutorial- Starting with CSS, how to use and integrate it.

CSS stands for Cascading Style Sheets. CSS is the very simple mechanism for adding style (this is fonts, colors, spacing) to Web pages. This post is about how to use css into an html documents and how these two can be work together. Step by step it is discussed of using css into html documents.

Step 1: Create a Html file.
Simply you can use notepad on windows or vi on unix to write a simple html file. You can use third party open source program like notepad++. But never use wordprocessor, such as Microsoft Word or OpenOffice. Because their outcome comes in different format and browser can't read it.

Note that in html comment starts with <!-- and ends with -->
My content of index.html is below.

<html>
<head>
<title>My first styled page</title>
</head>

<body>

<!-- Site navigation menu -->
<ul class="navigation_bar">
<li><a href="index.html">Home page</a>
<li><a href="products.html">Our Products</a>
<li><a href="contact_us.html">Contact us</a>
<li><a href="about_us.html">About us</a>
</ul>

<!-- Main content -->
<h1>This topic is one is for learning css</h1>

<p>Welcome to http://arjudba.blogspot.com

<p>It is just an example.
You can enhance it as you go on.
The style does not look so good.

<p>More learning materials
are coming soon.

<!-- Just publishing today's date with signature -->
<address>14th July, 2009.<br>
by Mohammad Abdul Momin Arju.</address>

</body>
</html>

In the example the tag <ul> introduces an "Unordered List", which means a list in which the items are not numbered. The <li> is the start of a "List Item." Note that <ul>, <p> does not need closing tags.

Step 2: Add some colours:
If you run codes of step1 you will see black text within white background. So with css we want to add some colours to background as well as to text. For css style we should make another file named style.css so that we can use that style for another html file. But in this post to make it easier, I am placing css styles in the same html file index.html. To do it we need to add a <style> element to the HTML file.

Let's see my style looks like,

<html>
<head>
<title>My first styled page</title>
<style type="text/css">
body {
color: green;
background-color: #ededed
}
</style>
</head>

<body>
etc...

Note that in case of adding css element there is followed by rules and each rule contains three part..

selector{
property:value;
}

1. The selector (in the example: "body"), which tells the browser which section of the web page will be affected by css style.

2. The property (in the example, 'color' and 'background-color' are both properties), which tells the browser what aspect of the layout is being set.

3. And the third one is value (in the example 'green' and '#ededed'), which gives the value for the style property.

Step 3: Add fonts
For good design and good look and feel you can add different fonts to different section of the page. For body Georgia font is used, if it is not available, Times New Roman or Times will be there, and if all else fails, the browser may use any other font with serifs.

For heading section Helvetica will be used. If not available Arial will be there, if both unavailable any fonts with sans-serif.

<html>
<head>
<title>My first styled page</title>
<style type="text/css">
body {
font-family: Georgia, "Times New Roman",
Times, serif;
color: purple;
background-color: #d8da3d }
h1 {
font-family: Helvetica, Arial, sans-serif }

</style>
</head>

Step 4: Add a navigation bar
We already have navigation menu at top of the page. But we want to move menu bar on left. This is done by css position property with a value of absolute. Also we need to position of body to the right so that menu and body does not overlap. We can move the body to the right by using padding-left property. So our css code now stands,

<html>
<head>
<title>My first styled page</title>
<style type="text/css">
body {
padding-left:14em;
font-family: Georgia, "Times New Roman",
Times, serif;
color: purple;
background-color: #d8da3d }
h1 {
font-family: Helvetica, Arial, sans-serif }
ul.navigation_bar{
position: absolute;
top: 2em;
left: 1em;
width: 9em }

</style>
</head>
<body>

Here measure 2em means 2 times the size of the current font. E.g., if the menu is displayed with a font of 14 points, then '2em' is 24 points. The 'em' is a very useful unit in CSS, since it can adapt automatically to the font that the reader happens to use.

Step 5: Style the links
Still now navigation menu looks like list. Using list-style-type property we will remove bullet. And we will make background as green of all menu items so that it looks like menu. To make each menu separate margin property would have a value. Also we will change the colours of the links. If user has not visited yet then make it blue and if user has visited link then we will make it purple.

Now it looks,

<html>
<head>
<title>My first styled page</title>
<style type="text/css">
body {
padding-left:14em;
font-family: Georgia, "Times New Roman",
Times, serif;
color: purple;
background-color: #d8da3d }
h1 {
font-family: Helvetica, Arial, sans-serif }
ul.navigation_bar{
list-style-type: none;
position: absolute;
top: 2em;
left: 1em;
width: 9em }
li{
background:green;
border:0;
padding:.5em;
margin:.3em;
}
a {
text-decoration: none }
a:link {
color: blue }
a:visited {
color: purple }

</style>
</head>

Step 6: Add a horizontal line
To make separate address from main page I am adding a horizontal line after body.
So just adding this line within style sheet.

address {
margin-top: 1em;
padding-top: 1em;
border-top: thin dotted }

Step 7: Put the style sheet in a separate file.
Now we are separating the syle sheet in another file so that we can use this style in many other web pages. Let's name this as style.css which looks like,

body {
padding-left:14em;
font-family: Georgia, "Times New Roman",
Times, serif;
color: purple;
background-color: #d8da3d }
h1 {
font-family: Helvetica, Arial, sans-serif }
ul.navigation_bar{
list-style-type: none;
position: absolute;
top: 2em;
left: 1em;
width: 9em }
li{
background:green;
border:0;
padding:.5em;
margin:.3em;
}
a {
text-decoration: none }
a:link {
color: blue }
a:visited {
color: purple }
address {
margin-top: 1em;
padding-top: 1em;
border-top: thin dotted }

Now from html file index.html reference it as,
<link rel="stylesheet" href="mystyle.css">
Our index.html looks like,

<html>
<head>
<title>My first styled page</title>
<link rel="stylesheet" href="style.css">

</style>
</head>


<body>

<!-- Site navigation menu -->
<ul class="navigation_bar">
<li><a href="index.html">Home page</a>
<li><a href="products.html">Our Products</a>
<li><a href="contact_us.html">Contact us</a>
<li><a href="about_us.html">About us</a>
</ul>

<!-- Main content -->
<h1>This topic is one is for learning css</h1>

<p>Welcome to http://arjudba.blogspot.com

<p>It is just an example.
You can enhance it as you go on.
The style does not look so good.

<p>More learning materials
are coming soon.

<!-- Just publishing today's date with signature -->
<address>14th July, 2009.<br>
by Mohammad Abdul Momin Arju.</address>

</body>
</html>

The output will be,







Sunday, July 12, 2009

SQL Decode

Syntax of SQL function Decode
The syntax of sql decode function is,

DECODE (expression,search,result[,default])
where search, result can be repeated many times as needed.
And default is optional.

How Decode Works
DECODE compares expression to each search value one by one. If expression is equal to a search, then corresponding result is returned. If expression does not match with search then Oracle returns default. As default is optional so it can be omitted and if omitted, then Oracle returns null.

Always remember that in a DECODE function, Oracle considers two nulls to be equivalent. So, if expression is null, then Oracle returns the result of the first search that is also null.

The maximum number of components in the DECODE function, including expression, searches, results, and default, is 255.

Data Conversion
- Oracle automatically converts expression and each search value to the datatype of the first search value before comparing. So the datatype of the first search value is a key role in decode.

- Oracle automatically converts the return value to the same datatype as the first result. So the first result plays a key role here.

- If the first result has the datatype CHAR or if the first result is null, then Oracle converts the return value to the datatype VARCHAR2. Again for the result it depends on the first datatype.

An example that demonstrate DECODE:
With an example below I will demonstrate DECODE, about how it works.
1)Create a table named country_list and insert data into it.

SQL> create table country_list(country_name varchar2(100));

Table created.

SQL> insert into country_list values('UK');

1 row created.

SQL> insert into country_list values('USA');

1 row created.

SQL> insert into country_list values('BAN');

1 row created.

SQL> insert into country_list values('PAK');

1 row created.

SQL> insert into country_list values('IND');

1 row created.

SQL> commit;

Commit complete.

SQL> select * from country_list;

COUNTRY_NAME
----------------------------------
UK
USA
BAN
PAK
IND

2)Now use DECODE function.
If the column value is UK then it will show United Kingdom.
If value is USA then it will show United States of America.
If value is BAN then it will show Bangladesh.
If value is PAK then it will show Pakistan.
If neither one matches then it will show default value OTHERS.

SQL> col country_name for a10
SQL> select country_name,
2 decode(country_name,'UK','United Kingdom',
3 'USA','United States of America',
4 'BAN','Bangladesh',
5 'PAK','PAKISTAN',
6 'OTHERS') from country_list;

COUNTRY_NA DECODE(COUNTRY_NAME,'UK'
---------- ------------------------
UK United Kingdom
USA United States of America
BAN Bangladesh
PAK PAKISTAN
IND OTHERS


You can also implement greater than or less than inside sql decode function. In case of number you can achieve that using SIGN function and in case of character you can achieve that using GREATEST function. Below is an example of using greatest function which will display whether name started less than M character or not.

SQL> select country_name, decode(
2 greatest(substr(country_name,1,1),'M'),'M'
3 ,'Name is between A to M','Name is between N to Z') from country_list;

COUNTRY_NA DECODE(GREATEST(SUBSTR
---------- ----------------------
UK Name is between N to Z
USA Name is between N to Z
BAN Name is between A to M
PAK Name is between N to Z
IND Name is between A to M

Related Documents

Saturday, July 11, 2009

ORA-39165: Schema SYS was not found ORA-39166, ORA-31655

Problem Description
This is a variant of error described in ORA-39166: Object was not found, SYS tables can't be exported. The ORA-39166 throws if you want to take data pump export of SYS objects using SYS user. And ORA-39165 throws if you want to take data pump export of SYS objects as a non-SYS user.

With a simple example problem is demonstrated here.

SQL> conn / as sysdba
Connected.
SQL> create table database_10g(col1 number);

Table created.

SQL> insert into database_10g values(23);

1 row created.

SQL> commit;

Commit complete.

SQL> host E:\oracle\product\10.2.0\db_2\BIN\expdp userid=arju/a tables=sys.database_10g dumpfile=sys_table_test.dmp

Export: Release 10.2.0.1.0 - Production on Saturday, 11 July, 2009 18:30:26

Copyright (c) 2003, 2005, Oracle. All rights reserved.

Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
Starting "ARJU"."SYS_EXPORT_TABLE_01": userid=arju/******** tables=sys.database_10g dumpfile=sys_table_test.dmp
Estimate in progress using BLOCKS method...
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 0 KB
ORA-39165: Schema SYS was not found.
ORA-39166: Object DATABASE_10G was not found.
ORA-31655: no data or metadata objects selected for job
Job "ARJU"."SYS_EXPORT_TABLE_01" completed with 3 error(s) at 18:30:36

It says both schema SYS and object table does not exist. But actually both are existed. Here is the proof.
SQL> conn arju/a
Connected.
SQL> desc sys.database_10g
Name Null? Type
----------------------------------------- -------- ----------------------------
COL1 NUMBER

SQL> select * from sys.database_10g ;

COL1
----------
23

SQL> select table_name, owner from dba_tables where table_name='DATABASE_10G';

TABLE_NAME OWNER
------------------------------ ------------------------------
DATABASE_10G SYS

Cause of the Problem
There is a restriction imposed in data pump export that SYS tables, objects are not exported even with full export option. Whenever we export by schemas=sys then role grants are exported but no data. Data pump does not allow to export system schemas like SYS, ORDSYS, EXFSYS, MDSYS, DMSYS, CTXSYS, ORDPLUGINS, LBACSYS, XDB, SI_INFORMTN_SCHEMA, DIP, DBSNMP and WMSYS in any mode.

Solution of the Problem
1)Use original export instead of data pump export to export SYS objects/schemas.

2)First using create table as select transfer SYS objects into non-restrictive schema and using data pump export data/tables from non-restrictive schema.

So the conclusion is the SYS schema, SYS tables cannot be used as a source schema for data pump export jobs.

Related Documents

In 11g data pump export schemas=sys do export only role grants

In the post http://arjudba.blogspot.com/2009/07/ora-39165-schema-sys-was-not-found-ora.html and http://arjudba.blogspot.com/2009/07/ora-39166-object-was-not-found-sys.html it is shown that the SYS schema objects or tables cannot be used as a source schema for data pump export jobs.

In this post it is shown if we specify schemas=sys option while data pump export then what it actually does. Of course no tables, indexes, constraint, procedures, packages, triggers are exported. Only role grant are exported.

SQL> host expdp userid=\"/ as sysdba\" dumpfile=sys_test_dump.dmp schemas=sys

Export: Release 11.1.0.6.0 - Production on Saturday, 11 July, 2009 18:17:04

Copyright (c) 2003, 2007, Oracle. All rights reserved.

Connected to: Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Starting "SYS"."SYS_EXPORT_SCHEMA_01": userid="/******** AS SYSDBA" dumpfile=sys_test_dump.dmp schemas=sys
Estimate in progress using BLOCKS method...
Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 0 KB
Processing object type SCHEMA_EXPORT/ROLE_GRANT
Master table "SYS"."SYS_EXPORT_SCHEMA_01" successfully loaded/unloaded
******************************************************************************
Dump file set for SYS.SYS_EXPORT_SCHEMA_01 is:
D:\APP\ARJU\ADMIN\ARJU\DPDUMP\SYS_TEST_DUMP.DMP
Job "SYS"."SYS_EXPORT_SCHEMA_01" successfully completed at 18:17:23

Let's see the contents inside dumpfile.
SQL> host impdp userid=\"/ as sysdba\" dumpfile=sys_test_dump.dmp sqlfile=inside_dump.txt

Import: Release 11.1.0.6.0 - Production on Saturday, 11 July, 2009 18:18:29

Copyright (c) 2003, 2007, Oracle. All rights reserved.

Connected to: Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Master table "SYS"."SYS_SQL_FILE_FULL_01" successfully loaded/unloaded
Starting "SYS"."SYS_SQL_FILE_FULL_01": userid="/******** AS SYSDBA" dumpfile=sys_test_dump.dmp sqlfile=inside_dump.txt
Processing object type SCHEMA_EXPORT/ROLE_GRANT
Job "SYS"."SYS_SQL_FILE_FULL_01" successfully completed at 18:18:33

The contents inside_dump.txt is as follows.
-- CONNECT SYS
ALTER SESSION SET EDITION = "ORA$BASE";
-- new object type path: SCHEMA_EXPORT/ROLE_GRANT
-- CONNECT SYSTEM
ALTER SESSION SET EDITION = "ORA$BASE";
GRANT "CONNECT" TO "SYS" WITH ADMIN OPTION;

GRANT "DBA" TO "SYS" WITH ADMIN OPTION;

GRANT "SELECT_CATALOG_ROLE" TO "SYS" WITH ADMIN OPTION;

GRANT "EXECUTE_CATALOG_ROLE" TO "SYS" WITH ADMIN OPTION;

GRANT "DELETE_CATALOG_ROLE" TO "SYS" WITH ADMIN OPTION;

GRANT "EXP_FULL_DATABASE" TO "SYS" WITH ADMIN OPTION;

GRANT "IMP_FULL_DATABASE" TO "SYS" WITH ADMIN OPTION;

GRANT "LOGSTDBY_ADMINISTRATOR" TO "SYS" WITH ADMIN OPTION;

GRANT "AQ_ADMINISTRATOR_ROLE" TO "SYS" WITH ADMIN OPTION;

GRANT "AQ_USER_ROLE" TO "SYS" WITH ADMIN OPTION;

GRANT "DATAPUMP_EXP_FULL_DATABASE" TO "SYS" WITH ADMIN OPTION;

GRANT "DATAPUMP_IMP_FULL_DATABASE" TO "SYS" WITH ADMIN OPTION;

GRANT "GATHER_SYSTEM_STATISTICS" TO "SYS" WITH ADMIN OPTION;

GRANT "RECOVERY_CATALOG_OWNER" TO "SYS" WITH ADMIN OPTION;

GRANT "SCHEDULER_ADMIN" TO "SYS" WITH ADMIN OPTION;

GRANT "HS_ADMIN_ROLE" TO "SYS" WITH ADMIN OPTION;

GRANT "OEM_ADVISOR" TO "SYS" WITH ADMIN OPTION;

GRANT "OEM_MONITOR" TO "SYS" WITH ADMIN OPTION;

GRANT "JAVAUSERPRIV" TO "SYS" WITH ADMIN OPTION;

GRANT "JAVAIDPRIV" TO "SYS" WITH ADMIN OPTION;

GRANT "JAVASYSPRIV" TO "SYS" WITH ADMIN OPTION;

GRANT "JAVADEBUGPRIV" TO "SYS" WITH ADMIN OPTION;

GRANT "EJBCLIENT" TO "SYS" WITH ADMIN OPTION;

GRANT "JMXSERVER" TO "SYS" WITH ADMIN OPTION;

GRANT "JAVA_ADMIN" TO "SYS" WITH ADMIN OPTION;

GRANT "JAVA_DEPLOY" TO "SYS" WITH ADMIN OPTION;

GRANT "CTXAPP" TO "SYS" WITH ADMIN OPTION;

GRANT "XDBADMIN" TO "SYS" WITH ADMIN OPTION;

GRANT "XDB_SET_INVOKER" TO "SYS" WITH ADMIN OPTION;

GRANT "AUTHENTICATEDUSER" TO "SYS" WITH ADMIN OPTION;

GRANT "XDB_WEBSERVICES" TO "SYS" WITH ADMIN OPTION;

GRANT "XDB_WEBSERVICES_WITH_PUBLIC" TO "SYS" WITH ADMIN OPTION;

GRANT "XDB_WEBSERVICES_OVER_HTTP" TO "SYS" WITH ADMIN OPTION;

GRANT "ORDADMIN" TO "SYS" WITH ADMIN OPTION;

GRANT "OLAPI_TRACE_USER" TO "SYS" WITH ADMIN OPTION;

GRANT "OLAP_XS_ADMIN" TO "SYS" WITH ADMIN OPTION;

GRANT "OLAP_DBA" TO "SYS" WITH ADMIN OPTION;

GRANT "CWM_USER" TO "SYS" WITH ADMIN OPTION;

GRANT "OLAP_USER" TO "SYS" WITH ADMIN OPTION;

GRANT "SPATIAL_WFS_ADMIN" TO "SYS" WITH ADMIN OPTION;

GRANT "WFS_USR_ROLE" TO "SYS" WITH ADMIN OPTION;

GRANT "SPATIAL_CSW_ADMIN" TO "SYS" WITH ADMIN OPTION;

GRANT "CSW_USR_ROLE" TO "SYS" WITH ADMIN OPTION;

GRANT "WKUSER" TO "SYS" WITH ADMIN OPTION;

GRANT "MGMT_USER" TO "SYS" WITH ADMIN OPTION;

GRANT "OWB$CLIENT" TO "SYS" WITH ADMIN OPTION;

GRANT "OWB_DESIGNCENTER_VIEW" TO "SYS" WITH ADMIN OPTION;

GRANT "OWB_USER" TO "SYS" WITH ADMIN OPTION;
Related Documents

ORA-39166: Object was not found, SYS tables can't be exported

In case of original export we could easily export the tables those were inside under SYS schema.

But whenever you try to export a table from sys schema using expdp it fails with ORA-39166: Object was not found. With a simple example the scenario is demonstrated below.

1)Log on as sysdba.
SQL> conn / as sysdba
Connected.

2)Create a test table and insert data into it.
SQL> create table test_export_for_sys(value1 number);

Table created.

SQL> insert into test_export_for_sys values(55);

1 row created.

SQL> commit;

Commit complete.

3)Try to take a data pump export of this table.
SQL> host expdp userid=\"/ as sysdba\" dumpfile=sys_test.dmp tables=test_export_for_sys

Export: Release 11.1.0.6.0 - Production on Saturday, 11 July, 2009 15:01:39

Copyright (c) 2003, 2007, Oracle. All rights reserved.

Connected to: Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Starting "SYS"."SYS_EXPORT_TABLE_01": userid="/******** AS SYSDBA" dumpfile=sys_test.dmp tables=test_export_for_sys
Estimate in progress using BLOCKS method...
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 0 KB
ORA-39166: Object TEST_EXPORT_FOR_SYS was not found.
ORA-31655: no data or metadata objects selected for job
Job "SYS"."SYS_EXPORT_TABLE_01" completed with 2 error(s) at 15:01:45

But in the database there exists test_export_for_sys table,

SQL> desc test_export_for_sys
Name Null? Type
----------------------------------------- -------- -------------
VALUE1 NUMBER

SQL> select * from test_export_for_sys;

VALUE1
----------
55

SQL> show user;
USER is "SYS"

If you try to export schema also no tables are exported.
SQL> host expdp userid=\"/ as sysdba\" dumpfile=sys_test_schema.dmp schemas=sys

Export: Release 11.1.0.6.0 - Production on Saturday, 11 July, 2009 19:14:56

Copyright (c) 2003, 2007, Oracle. All rights reserved.

Connected to: Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Starting "SYS"."SYS_EXPORT_SCHEMA_01": userid="/******** AS SYSDBA" dumpfile=sys_test_schema.dmp schemas=sys
Estimate in progress using BLOCKS method...
Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 0 KB
Processing object type SCHEMA_EXPORT/ROLE_GRANT
Master table "SYS"."SYS_EXPORT_SCHEMA_01" successfully loaded/unloaded
******************************************************************************
Dump file set for SYS.SYS_EXPORT_SCHEMA_01 is:
D:\APP\ARJU\ADMIN\ARJU\DPDUMP\SYS_TEST_SCHEMA.DMP
Job "SYS"."SYS_EXPORT_SCHEMA_01" successfully completed at 19:16:12


But this is not the fact in case of original export. Here is the original export output,

SQL> host exp userid=\"/ as sysdba\" file=sys_test.dmp tables=test_export_for_sys

Export: Release 11.1.0.6.0 - Production on Sat Jul 11 17:42:29 2009

Copyright (c) 1982, 2007, Oracle. All rights reserved.


Connected to: Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Export done in WE8MSWIN1252 character set and AL16UTF16 NCHAR character set

About to export specified tables via Conventional Path ...
. . exporting table TEST_EXPORT_FOR_SYS 1 rows exported
Export terminated successfully without warnings.

Solution of the Problem
This is the restriction imposed in oracle data pump. A number of system schemas tables cannot be exported because they are not user schemas, they contain Oracle-managed data and metadata. As in every schemas there by default system schemas exist. Data pump utility designed for transferring data, not the database; so not the system schemas. However if you want to export sys tables like SYS.AUD$ then first transfer that table into non-restricted schema and export the table from non restricted schema.

Related Documents