2006年03月07日
  1  堆、栈及静态数据区详解
  2
  3  原作者:风小云 
  4  原文链接地址:http://blog.csdn.net/welcome_ck/archive/2004/12/24/227961.aspx
  5
  6  五大内存分区
  7      在C++中,内存分成5个区,他们分别是堆、栈、自由存储区、全局/静态存储区和常量
  8  存储区。
  9
 10      栈,就是那些由编译器在需要的时候分配,在不需要的时候自动清楚的变量的存储区。
 11  里面的变量通常是局部变量、函数参数等。
 12
 13      堆,就是那些由new分配的内存块,他们的释放编译器不去管,由我们的应用程序去控
 14  制,一般一个new就要对应一个delete。如果程序员没有释放掉,那么在程序结束后,操作
 15  系统会自动回收。
 16
 17      自由存储区,就是那些由malloc等分配的内存块,他和堆是十分相似的,不过它是用
 18  free来结束自己的生命的。
 19
 20      全局/静态存储区,全局变量和静态变量被分配到同一块内存中,在以前的C语言中,
 21  全局变量又分为初始化的和未初始化的,在C++里面没有这个区分了,他们共同占用同一块
 22  内存区。
 23
 24      常量存储区,这是一块比较特殊的存储区,他们里面存放的是常量,不允许修改(当
 25  然,你要通过非正当手段也可以修改,而且方法很多)
 26
 27      明确区分堆与栈,在bbs上,堆与栈的区分问题,似乎是一个永恒的话题,由此可见,
 28  初学者对此往往是混淆不清的,所以我决定拿他第一个开刀。
 29
 30      首先,我们举一个例子:
 31      void f() { int* p=new int[5]; }
 32      这条短短的一句话就包含了堆与栈,看到new,我们首先就应该想到,我们分配了一块
 33  堆内存,那么指针p呢?他分配的是一块栈内存,所以这句话的意思就是:在栈内存中存放
 34  了一个指向一块堆内存的指针p。在程序会先确定在堆中分配内存的大小,然后调用operator
 35   new分配内存,然后返回这块内存的首地址,放入栈中,他在VC6下的汇编代码如下:
 36
 37      00401028   push        14h
 38      0040102A   call        operator new (00401060)
 39      0040102F   add         esp,4
 40      00401032   mov         dword ptr [ebp-8],eax
 41      00401035   mov         eax,dword ptr [ebp-8]
 42      00401038   mov         dword ptr [ebp-4],eax
 43
 44      这里,我们为了简单并没有释放内存,那么该怎么去释放呢?是delete p么?澳,错了,
 45  应该是delete []p,这是为了告诉编译器:我删除的是一个数组,VC6就会根据相应的Cookie
 46  信息去进行释放内存的工作。
 47
 48      好了,我们回到我们的主题:堆和栈究竟有什么区别?
 49      主要的区别由以下几点:
 50      1、管理方式不同;
 51      2、空间大小不同;
 52      3、能否产生碎片不同;
 53      4、生长方向不同;
 54      5、分配方式不同;
 55      6、分配效率不同;
 56
 57      管理方式:对于栈来讲,是由编译器自动管理,无需我们手工控制;对于堆来说,释放
 58  工作由程序员控制,容易产生memory leak。
 59
 60      空间大小:一般来讲在32位系统下,堆内存可以达到4G的空间,从这个角度来看堆内存
 61  几乎是没有什么限制的。但是对于栈来讲,一般都是有一定的空间大小的,例如,在VC6下
 62  面,默认的栈空间大小是1M(好像是,记不清楚了)。
 63
 64      当然,我们可以修改:
 65      打开工程,依次操作菜单如下:Project->Setting->Link,在Category 中选中Output,
 66  然后在Reserve中设定堆栈的最大值和commit。注意:reserve最小值为4Byte;commit是保
 67  留在虚拟内存的页文件里面,它设置的较大会使栈开辟较大的值,可能增加内存的开销和启
 68  动时间。
 69
 70      碎片问题:对于堆来讲,频繁的new/delete势必会造成内存空间的不连续,从而造成大
 71  量的碎片,使程序效率降低。对于栈来讲,则不会存在这个问题,因为栈是先进后出的队列,
 72  他们是如此的一一对应,以至于永远都不可能有一个内存块从栈中间弹出,在他弹出之前,
 73  在他上面的后进的栈内容已经被弹出,详细的可以参考数据结构,这里我们就不再一一讨论了。
 74
 75      生长方向:对于堆来讲,生长方向是向上的,也就是向着内存地址增加的方向;对于栈
 76  来讲,它的生长方向是向下的,是向着内存地址减小的方向增长。
 77
 78      分配方式:堆都是动态分配的,没有静态分配的堆。栈有2种分配方式:静态分配和动
 79  态分配。静态分配是编译器完成的,比如局部变量的分配。动态分配由alloca函数进行分
 80  配,但是栈的动态分配和堆是不同的,他的动态分配是由编译器进行释放,无需我们手工实现。
 81
 82      分配效率:栈是机器系统提供的数据结构,计算机会在底层对栈提供支持:分配专门的
 83  寄存器存放栈的地址,压栈出栈都有专门的指令执行,这就决定了栈的效率比较高。堆则是
 84  C/C++函数库提供的,它的机制是很复杂的,例如为了分配一块内存,库函数会按照一定的
 85  算法(具体的算法可以参考数据结构/操作系统)在堆内存中搜索可用的足够大小的空间,
 86  如果没有足够大小的空间(可能是由于内存碎片太多),就有可能调用系统功能去增加程序
 87  数据段的内存空间,这样就有机会分到足够大小的内存,然后进行返回。显然,堆的效率比
 88  栈要低得多。
 89
 90      从这里我们可以看到,堆和栈相比,由于大量new/delete的使用,容易造成大量的内存
 91  碎片;由于没有专门的系统支持,效率很低;由于可能引发用户态和核心态的切换,内存的
 92  申请,代价变得更加昂贵。所以栈在程序中是应用最广泛的,就算是函数的调用也利用栈去
 93  完成,函数调用过程中的参数,返回地址,EBP和局部变量都采用栈的方式存放。所以,我
 94  们推荐大家尽量用栈,而不是用堆。
 95
 96      虽然栈有如此众多的好处,但是由于和堆相比不是那么灵活,有时候分配大量的内存空
 97  间,还是用堆好一些。
 98
 99      无论是堆还是栈,都要防止越界现象的发生(除非你是故意使其越界),因为越界的结
100  果要么是程序崩溃,要么是摧毁程序的堆、栈结构,产生以想不到的结果,就算是在你的程
101  序运行过程中,没有发生上面的问题,你还是要小心,说不定什么时候就崩掉,那时候debug
102  可是相当困难的:)
103
104      对了,还有一件事,如果有人把堆栈合起来说,那它的意思是栈,可不是堆,呵呵,清
105  楚了?static用来控制变量的存储方式和可见性,函数内部定义的变量,在程序执行到它的
106  定义处时,编译器为它在栈上分配空间,函数在栈上分配的空间在此函数执行结束时会释放
107  掉,这样就产生了一个问题: 如果想将函数中此变量的值保存至下一次调用时,如何实现?
108  最容易想到的方法是定义一个全局的变量,但定义为一个全局变量有许多缺点,最明显的缺
109  点是破坏了此变量的访问范围(使得在此函数中定义的变量,不仅仅受此函数控制)。
110  需要一个数据对象为整个类而非某个对象服务,同时又力求不破坏类的封装性,即要求此成员
111  隐藏在类的内部,对外不可见。
112
113      static的内部机制:
114      静态数据成员要在程序一开始运行时就必须存在。因为函数在程序运行中被调用,所以
115  静态数据成员不能在任何函数内分配空间和初始化。这样,它的空间分配有三个可能的地方,
116  一是作为类的外部接口的头文件,那里有类声明;二是类定义的内部实现,那里有类的成员
117  函数定义;三是应用程序的main()函数前的全局数据声明和定义处。
118
119      静态数据成员要实际地分配空间,故不能在类的声明中定义(只能声明数据成员)。类
120  声明只声明一个类的“尺寸和规格”,并不进行实际的内存分配,所以在类声明中写成定义
121  是错误的。它也不能在头文件中类声明的外部定义,因为那会造成在多个使用该类的源文件
122  中,对其重复定义。
123
124      static被引入以告知编译器,将变量存储在程序的静态存储区而非栈上空间,静态数据
125  成员按定义出现的先后顺序依次初始化,注意静态成员嵌套时,要保证所嵌套的成员已经初
126  始化了。消除时的顺序是初始化的反顺序。
127
128      static的优势:
129      可以节省内存,因为它是所有对象所公有的,因此,对多个对象来说,静态数据成员只
130  存储一处,供所有对象共用。静态数据成员的值对每个对象都是一样,但它的值是可以更新
131  的。只要对静态数据成员的值更新一次,保证所有对象存取更新后的相同的值,这样可以提
132  高时间效率。
133
134      引用静态数据成员时,采用如下格式:
135      <类名>::<静态成员名>
136
137      如果静态数据成员的访问权限允许的话(即public的成员),可在程序中,按上述格式
138  来引用静态数据成员。
139
140      PS:
141      (1)类的静态成员函数是属于整个类而非类的对象,所以它没有this指针,这就导致
142  了它仅能访问类的静态数据和静态成员函数。
143
144      (2)不能将静态成员函数定义为虚函数。
145
146      (3)由于静态成员声明于类中,操作于其外,所以对其取地址操作,就多少有些特殊
147  ,变量地址是指向其数据类型的指针 ,函数地址类型是一个“nonmember函数指针”。
148
149      (4)由于静态成员函数没有this指针,所以就差不多等同于nonmember函数,结果就
150  产生了一个意想不到的好处:成为一个callback函数,使得我们得以将C++和C-based X W
151  indow系统结合,同时也成功的应用于线程函数身上。
152
153     (5)static并没有增加程序的时空开销,相反她还缩短了子类对父类静态成员的访问
154  时间,节省了子类的内存空间。
155
156     (6)静态数据成员在<定义或说明>时前面加关键字static。
157
158     (7)静态数据成员是静态存储的,所以必须对它进行初始化。
159
160     (8)静态成员初始化与一般数据成员初始化不同:
161        初始化在类体外进行,而前面不加static,以免与一般静态变量或对象相混淆;
162        初始化时不加该成员的访问权限控制符private,public等;
163             初始化时使用作用域运算符来标明它所属类;
164             所以我们得出静态数据成员初始化的格式:
165           <数据类型><类名>::<静态数据成员名>=<值>
166
167     (9)为了防止父类的影响,可以在子类定义一个与父类相同的静态变量,以屏蔽父类的影
168  响。这里有一点需要注意:我们说静态成员为父类和子类共享,但我们有重复定义了静态成
169  员,这会不会引起错误呢?不会,我们的编译器采用了一种绝妙的手法:name-mangling 用
170  以生成唯一的标志。
171
2006年03月06日
  1  C/C++程序员应聘常见面试题深入剖析
  2
  3  作者:宋宝华  e-mail:21cnbao@21cn.com    出处:软件报
  4
  5  1.引言
  6
  7      本文的写作目的并不在于提供C/C++程序员求职面试指导,而旨在从技术上分析面试题
  8  的内涵。文中的大多数面试题来自各大论坛,部分试题解答也参考了网友的意见。
  9
 10      许多面试题看似简单,却需要深厚的基本功才能给出完美的解答。企业要求面试者写
 11  一个最简单的strcpy函数都可看出面试者在技术上究竟达到了怎样的程度,我们能真正写
 12  好一个strcpy函数吗?我们都觉得自己能,可是我们写出的strcpy很可能只能拿到10分中
 13  的2分。读者可从本文看到strcpy函数从2分到10分解答的例子,看看自己属于什么样的层
 14  次。此外,还有一些面试题考查面试者敏捷的思维能力。分析这些面试题,本身包含很强
 15  的趣味性;而作为一名研发人员,通过对这些面试题的深入剖析则可进一步增强自身的内
 16  功。
 17
 18
 19  2.找错题
 20
 21
 22  试题1:
 23
 24  void test1()
 25  {
 26
 27     char string[10];
 28
 29     char* str1 = "0123456789";
 30
 31     strcpy( string, str1 );
 32
 33  }
 34
 35  试题2:
 36
 37  void test2()
 38  {
 39
 40     char string[10], str1[10];
 41
 42     int i;
 43
 44     for(i=0; i<10; i++)
 45     {
 46          str1[i] = 'a';
 47     }
 48
 49     strcpy( string, str1 );
 50
 51  }
 52
 53
 54  试题3:
 55
 56  void test3(char* str1)
 57
 58  {
 59
 60     char string[10];
 61
 62     if( strlen( str1 ) <= 10 )
 63
 64     {
 65
 66         strcpy( string, str1 );
 67
 68     }
 69  }
 70
 71  解答:
 72
 73  试题1字符串str1需要11个字节才能存放下(包括末尾的’\0’),而string只有10个字节
 74  的空间,strcpy会导致数组越界;
 75
 76  对试题2,如果面试者指出字符数组str1不能在数组内结束可以给3分;如果面试者指出
 77  strcpy(string, str1)调用使得从str1内存起复制到string内存起所复制的字节数具有不
 78  确定性可以给7分,在此基础上指出库函数strcpy工作方式的给10分;
 79
 80  对试题3,if(strlen(str1) <= 10)应改为if(strlen(str1) < 10),因为strlen的结果未
 81  统计’\0’所占用的1个字节。
 82
 83  剖析:
 84  考查对基本功的掌握:
 85
 86  (1)字符串以’\0’结尾;
 87
 88  (2)对数组越界把握的敏感度;
 89
 90  (3)库函数strcpy的工作方式,如果编写一个标准strcpy函数的总分值为10,下面给出几
 91       个不同得分的答案:
 92
 93  2分:
 94  void strcpy( char *strDest, char *strSrc )
 95
 96  {
 97
 98    while( (*strDest++ = * strSrc++) != ‘\0’ );
 99
100  }
101
102  4分:
103  void strcpy( char *strDest, const char *strSrc )
104  //将源字符串加const,表明其为输入参数,加2分
105  {
106
107    while( (*strDest++ = * strSrc++) != ‘\0’ );
108
109  }
110
111  7分:
112  void strcpy(char *strDest, const char *strSrc)
113
114  {
115  //对源地址和目的地址加非0断言,加3分
116
117   assert( (strDest != NULL) && (strSrc != NULL) );
118
119   while( (*strDest++ = * strSrc++)  !=  ‘\0’ );
120
121  }
122
123  10分:
124  //为了实现链式操作,将目的地址返回,加3分!
125  char * strcpy( char *strDest, const char *strSrc )
126  {
127
128   assert( (strDest != NULL) && (strSrc != NULL) );
129
130    char *address = strDest;
131
132   while( (*strDest++ = * strSrc++) != ‘\0’ );
133
134    return address;
135
136  }
137
138  从2分到10分的几个答案我们可以清楚的看到,小小的strcpy竟然暗藏着这么多玄机,真不
139  是盖的!需要多么扎实的基本功才能写一个完美的strcpy啊!
140
141
142  (4)对strlen的掌握,它没有包括字符串末尾的'\0'。
143
144  读者看了不同分值的strcpy版本,应该也可以写出一个10分的strlen函数了,完美的版本为:
145
146  int strlen( const char *str )    //输入参数const
147  {
148
149       assert( strt != NULL );    //断言字符串地址非0
150
151       int len;
152
153       while( (*str++) != '\0' )
154       {
155              len++;
156       }
157
158       return len;
159
160  }
161
162  试题4:
163  void GetMemory( char *p )
164  {
165
166    p = (char *) malloc( 100 );
167
168  }
169
170  void Test( void )
171  {
172
173    char *str = NULL;
174
175    GetMemory( str );
176
177    strcpy( str, "hello world" );
178
179    printf( str );
180
181  }
182
183
184  试题5:
185  char *GetMemory( void )
186  {
187
188       char p[] = "hello world";
189
190       return p;
191
192  }
193
194  void Test( void )
195  {
196
197       char *str = NULL;
198
199       str = GetMemory();
200
201       printf( str );
202
203  }
204
205  试题6:
206  void GetMemory( char **p, int num )
207  {
208       *p = (char *) malloc( num );
209  }
210
211  void Test( void )
212  {
213
214       char *str = NULL;
215
216       GetMemory( &str, 100 );
217
218       strcpy( str, "hello" );
219
220       printf( str );
221
222  }
223
224
225
226  试题7:
227  void Test( void )
228  {
229
230       char *str = (char *) malloc( 100 );
231
232       strcpy( str, "hello" );
233
234       free( str );
235
236       ...  //省略的其它语句
237
238  }
239
240  解答:
241  试题4传入中GetMemory( char *p )函数的形参为字符串指针,在函数内部修改形参并不能
242  真正的改变传入形参的值,执行完char *str = NULL; GetMemory( str ); 后的str仍然为
243  NULL;
244
245  试题5中
246    char p[] = "hello world";
247    return p;
248  的p[]数组为函数内的局部自动变量,在函数返回后,内存已经被释放。这是许多程序员常
249  犯的错误,其根源在于不理解变量的生存期。
250
251  试题6的GetMemory避免了试题4的问题,传入GetMemory的参数为字符串指针的指针,但是
252  在GetMemory中执行申请内存及赋值语句
253
oracle面试题一句话问答
1.    Explain the difference between a hot backup and a cold backup and the benefits associated with each.

A hot backup is basically taking a backup of the database while it is still up and running and it must be in archive log mode. A cold backup is taking a backup of the database while it is shut down and does not require being in archive log mode. The benefit of taking a hot backup is that the database is still available for use while the backup is occurring and you can recover the database to any point in time. The benefit of taking a cold backup is that it is typically easier to administer the backup and recovery process. In addition, since you are taking cold backups the database does not require being in archive log mode and thus there will be a slight performance gain as the database is not cutting archive logs to disk.

2.     You have just had to restore from backup and do not have any control files. How would you go about bringing up this database?

I would create a text based backup control file, stipulating where on disk all the data files where and then issue the recover command with the using backup control file clause.

3.     How do you switch from an init.ora file to a spfile?

Issue the create spfile from pfile command.

4.     Explain the difference between a data block, an extent and a segment.

A data block is the smallest unit of logical storage for a database object. As objects grow they take chunks of additional storage that are composed of contiguous data blocks. These groupings of contiguous data blocks are called extents. All the extents that an object takes when grouped together are considered the segment of the database object.

5.     Give two examples of how you might determine the structure of the table DEPT.

Use the describe command or use the dbms_metadata.get_ddl package.

6.     Where would you look for errors from the database engine?

In the alert log.

7.     Compare and contrast TRUNCATE and DELETE for a table.

Both the truncate and delete command have the desired outcome of getting rid of all the rows in a table. The difference between the two is that the truncate command is a DDL operation and just moves the high water mark and produces a now rollback. The delete command, on the other hand, is a DML operation, which will produce a rollback and thus take longer to complete.

8.     Give the reasoning behind using an index.

Faster access to data blocks in a table.

9.     Give the two types of tables involved in producing a star schema and the type of data they hold.

Fact tables and dimension tables. A fact table contains measurements while dimension tables will contain data that will help describe the fact tables.

10. . What type of index should you use on a fact table?

A Bitmap index.

11. Give two examples of referential integrity constraints.

A primary key and a foreign key.

12. A table is classified as a parent table and you want to drop and re-create it. How would you do this without affecting the children tables?

Disable the foreign key constraint to the parent, drop the table, re-create the table, enable the foreign key constraint.

13. Explain the difference between ARCHIVELOG mode and NOARCHIVELOG mode and the benefits and disadvantages to each.

ARCHIVELOG mode is a mode that you can put the database in for creating a backup of all transactions that have occurred in the database so that you can recover to any point in time. NOARCHIVELOG mode is basically the absence of ARCHIVELOG mode and has the disadvantage of not being able to recover to any point in time. NOARCHIVELOG mode does have the advantage of not having to write transactions to an archive log and thus increases the performance of the database slightly.

14. What command would you use to create a backup control file?

Alter database backup control file to trace.

15. Give the stages of instance startup to a usable state where normal users may access it.

STARTUP NOMOUNT – Instance startup

STARTUP MOUNT – The database is mounted

STARTUP OPEN – The database is opened

16. What column differentiates the V$ views to the GV$ views and how?

The INST_ID column which indicates the instance in a RAC environment the information came from.

17. How would you go about generating an EXPLAIN plan?

Create a plan table with utlxplan.sql.

Use the explain plan set statement_id = ‘tst1′ into plan_table for a SQL statement

Look at the explain plan with utlxplp.sql or utlxpls.sql

18. How would you go about increasing the buffer cache hit ratio?

Use the buffer cache advisory over a given workload and then query the v$db_cache_advice table. If a change was necessary then I would use the alter system set db_cache_size command.

19. Explain an ORA-01555

You get this error when you get a snapshot too old within rollback. It can usually be solved by increasing the undo retention or increasing the size of rollbacks. You should also look at the logic involved in the application getting the error message.

20. Explain the difference between $ORACLE_HOME and $ORACLE_BASE.

ORACLE_BASE is the root directory for oracle. ORACLE_HOME located beneath ORACLE_BASE is where the oracle products reside.


21.  How would you determine the time zone under which a database was operating?

select DBTIMEZONE from dual;
22.  Explain the use of setting GLOBAL_NAMES equal to TRUE.

Setting GLOBAL_NAMES dictates how you might connect to a database. This variable is either TRUE or FALSE and if it is set to TRUE it enforces database links to have the same name as the remote database to which they are linking.

23.  What command would you use to encrypt a PL/SQL application?

WRAP

24.  Explain the difference between a FUNCTION, PROCEDURE and PACKAGE.

A function and procedure are the same in that they are intended to be a collection of PL/SQL code that carries a single task. While a procedure does not have to return any values to the calling application, a function will return a single value. A package on the other hand is a collection of functions and procedures that are grouped together based on their commonality to a business function or application.

25.  Explain the use of table functions.

Table functions are designed to return a set of rows through PL/SQL logic but are intended to be used as a normal table or view in a SQL statement. They are also used to pipeline information in an ETL process.

26.  Name three advisory statistics you can collect.

Buffer Cache Advice, Segment Level Statistics, & Timed Statistics

27.  Where in the Oracle directory tree structure are audit traces placed?

In unix $ORACLE_HOME/rdbms/audit, in Windows the event viewer

28.  Explain materialized views and how they are used.

Materialized views are objects that are reduced sets of information that have been summarized, grouped, or aggregated from base tables. They are typically used in data warehouse or decision support systems.

29.  When a user process fails, what background process cleans up after it?

PMON

30.  What background process refreshes materialized views?

The Job Queue Processes.

31.  How would you determine what sessions are connected and what resources they are waiting for?

Use of V$SESSION and V$SESSION_WAIT

32.  Describe what redo logs are.

Redo logs are logical and physical structures that are designed to hold all the changes made to a database and are intended to aid in the recovery of a database.

33.  How would you force a log switch?

ALTER SYSTEM SWITCH LOGFILE;
34.  Give two methods you could use to determine what DDL changes have been made.

You could use Logminer or Streams

35.  What does coalescing a tablespace do?

Coalescing is only valid for dictionary-managed tablespaces and de-fragments space by combining neighboring free extents into large single extents.

36.  What is the difference between a TEMPORARY tablespace and a PERMANENT tablespace?

A temporary tablespace is used for temporary objects such as sort structures while permanent tablespaces are used to store those objects meant to be used as the true objects of the database.

37.  Name a tablespace automatically created when you create a database.

The SYSTEM tablespace.

38.  When creating a user, what permissions must you grant to allow them to connect to the database?

Grant the CONNECT to the user.

39.  How do you add a data file to a tablespace?

ALTER TABLESPACE <tablespace_name>; ADD DATAFILE <datafile_name>; SIZE <size>;
40.  How do you resize a data file?

ALTER DATABASE DATAFILE <datafile_name>; RESIZE <new_size>;;
41.  What view would you use to look at the size of a data file?

DBA_DATA_FILES
42.  What view would you use to determine free space in a tablespace?

DBA_FREE_SPACE
43.  How would you determine who has added a row to a table?

Turn on fine grain auditing for the table.

44.  How can you rebuild an index?

ALTER INDEX <index_name>; REBUILD;
45.  Explain what partitioning is and what its benefit is.

Partitioning is a method of taking large tables and indexes and splitting them into smaller, more manageable pieces.

46.  You have just compiled a PL/SQL package but got errors, how would you view the errors?

SHOW ERRORS
47.  How can you gather statistics on a table?

The ANALYZE command.

48.  How can you enable a trace for a session?

Use the DBMS_SESSION.SET_SQL_TRACE or

Use ALTER SESSION SET SQL_TRACE = TRUE;

49.  What is the difference between the SQL*Loader and IMPORT utilities?

These two Oracle utilities are used for loading data into the database. The difference is that the import utility relies on the data being produced by another Oracle utility EXPORT while the SQL*Loader utility allows data to be loaded that has been produced by other utilities from different data sources just so long as it conforms to ASCII formatted or delimited files.

50.  Name two files used for network connection to a database.

TNSNAMES.ORA and SQLNET.ORA

Technical – UNIX
Every DBA should know something about the operating system that the database will be running on. The questions here are related to UNIX but you should equally be able to answer questions related to common Windows environments.

1.  How do you list the files in an UNIX directory while also showing hidden files?

ls -ltra
2.  How do you execute a UNIX command in the background?

Use the "&"

3.  What UNIX command will control the default file permissions when files are created?

Umask

4.  Explain the read, write, and execute permissions on a UNIX directory.

Read allows you to see and list the directory contents.

Write allows you to create, edit and delete files and subdirectories in the directory.

Execute gives you the previous read/write permissions plus allows you to change into the directory and execute programs or shells from the directory.

5.  the difference between a soft link and a hard link?

A symbolic (soft) linked file and the targeted file can be located on the same or different file system while for a hard link they must be located on the same file system.

6.  Give the command to display space usage on the UNIX file system.

df -lk
7.  Explain iostat, vmstat and netstat.

Iostat reports on terminal, disk and tape I/O activity.

Vmstat reports on virtual memory statistics for processes, disk, tape and CPU activity.

Netstat reports on the contents of network data structures.

8.  How would you change all occurrences of a value using VI?

Use :%s/<old>;/<new>;/g

9.  Give two UNIX kernel parameters that effect an Oracle install

SHMMAX & SHMMNI

10.  Briefly, how do you install Oracle software on UNIX.

Basically, set up disks, kernel parameters, and run orainst.
2006年03月02日
SQL> explain plan for select count(*) from hr.employees;
Explained
SQL> select * from table(dbms_xplan.display);
PLAN_TABLE_OUTPUT
——————————————————————————–
Plan hash value: 2021404829
————————————————————————————————————————-
| Id | Operation                        | Name                   | Rows  | Bytes| Cost (%CPU)| Time
————————————————————————————————————————-
|   0 | SELECT STATEMENT |                                |     1      |           |     1   (0)          | 00:00:01
|   1 | SORT AGGREGATE    |                                 |     1      |          |                          |
|   2 |   INDEX FULL SCAN    | EMP_EMAIL_UK |   107   |           |     1   (0)           | 00:00:01
————————————————————————————————————————-
9 rows selected
2006年02月23日

ActiveRecord::Base.establish_connection(
     :adapter => "oci",
     :username => "system",
     :password => "manager",
     :host => "orcl_db"
           )

require ‘win32ole’

excel = WIN32OLE.new("excel.application")       
excel.Visible = false
excel.WorkBooks.Open("c:\\test.xls")
excel.WorkSheets("sheet1").Activate

excel.Cells(2,3).value = "张三"
excel.Cells(3,3).value = "王二"

excel.ActiveWorkbook.Close(0)
excel.Quit()

2006年02月20日

在命令行下敲入:
cleanmgr /sageset:99              設定
cleanmgr /sagerun:99             執行

2006年02月14日

问题:
       运行Impromptu报告: workspace directory does not exist

解决方法:
      编辑cer4.ini文件
      [Cognos Locations]
      Impromptu 7.1=C:\Program Files\Cognos\cer4
      Impromptu Workspace 7.3=C:\Program Files\Cognos\cer4\bin\User Workspace

2006年01月11日

在vimrc 中定义,Alt + N 切换第 N 个 buffer,Alt + ` 和 Alt + ~ 在所有 buffer 之间循环切换
imap <M-1> <C-O>:hide buffer 1<cr>
imap <M-2> <C-O>:hide buffer 2<cr>
imap <M-3> <C-O>:hide buffer 3<cr>
imap <M-4> <C-O>:hide buffer 4<cr>
imap <M-5> <C-O>:hide buffer 5<cr>
imap <M-6> <C-O>:hide buffer 6<cr>
imap <M-7> <C-O>:hide buffer 7<cr>
imap <M-8> <C-O>:hide buffer 8<cr>
imap <M-9> <C-O>:hide buffer 9<cr>
nmap <M-1> :hide buffer 1<cr>
nmap <M-2> :hide buffer 2<cr>
nmap <M-3> :hide buffer 3<cr>
nmap <M-4> :hide buffer 4<cr>
nmap <M-5> :hide buffer 5<cr>
nmap <M-6> :hide buffer 6<cr>
nmap <M-7> :hide buffer 7<cr>
nmap <M-8> :hide buffer 8<cr>
nmap <M-9> :hide buffer 9<cr>
imap <M-`> <C-O>:hide bnext<cr>
nmap <M-`> :hide bnext<cr>
imap <M-~> <C-O>:hide bprev<cr>
nmap <M-~> :hide bprev<cr>

编辑_vimrc文件,加入
if  has("gui")
    colorscheme asu1dark
else
    colorscheme default
endif