What is Software Assurance (SA)? | Networking

Software Assurance (SA) is a way for Volume Licensing customers to keep up to date with the latest and most innovative Microsoft products. Customers acquire the right to install any new release of a product covered in the agreement during the term of the coverage.

What is the difference between a Device CAL and a User CAL? | Networking

A Windows Server Device CAL permits one device to access or use the server software; whereas, a Windows Server User CAL permits one user irrespective of a device to access or use the server software.

What is Volume Licensing? | Networking

When you acquire licenses from Microsoft and its partners in certain quantities or volumes, they offer discounts from their retail product prices. Volume Licensing programs offer companies of all sizes an economical way to buy and manage multiple software licenses for as few as five desktops.

Is Windows Server 2008 a prerequisite for Windows Server 2008 R2? | Networking

No, Windows Server 2008 or Windows Server 2003 R2 can be upgraded to Windows Server 2008 R2.

What is File Classification Infrastructure (FCI)? | Networking

FCI provides a built-in solution to classify and manage files to users and help them to save time and money. Administrators can automatically classify files based on content and location, generate reports, and schedule file management tasks to manage data.

Explain the difference between Windows Server 2008 R2 license and Windows Server 2008 CAL. | Networking

The Windows Server 2008 CAL grants the right to a device or user to access the server software; whereas, the Windows Server 2008 R2 license gives the license holder the right to create, copy, store, and run the server software.

What is the function of Hyper-V Processor Compatibility Mode for live migration? | Networking

Hyper-V Processor Compatibility Mode allows live migration across different CPU versions within the same processor family, such as Intel Core 2 to Intel Pentium 4 or AMD Opteron to AMD Athlon. It also enables migration across a broader range of server host hardware.

What is the role of live migration in Windows 2008 R2? | Networking

Live migration enables customers to move virtual machines from one host to another with no perceivable downtime. It facilitates hardware maintenance, and upgrades manual failover and the consolidation of workloads on fewer servers.

What is Netsh? | Networking

Netsh is a command-line scripting utility that is used to display or modify the network configuration of a computer that is currently running. Both remote computers and local computers can be configured by using the netsh command. Netsh also provides a scripting feature that allows you to run a group of commands in batch mode against a specified computer.

What is the role of multiple active firewall profiles? | Networking

Multiple active firewall profiles enable the firewall rules most appropriate for each network adapter based on the network to which it is connected.

What is the role of NDF, Network Tracing, and Netsh Trace? | Networking

NDF, Network Tracing, and Netsh Trace integrate the Network Diagnostics Framework with Network Tracing and a new Netsh context, Netsh Trace, to simplify and consolidate network connectivity troubleshooting processes.

What is the role of mobile broadband device support? | Networking

Mobile broadband device support provides a driver-based model for devices that are used to access a mobile broadband network.

What is the role of URL-based QoS? | Networking


URL-based QoS enables administrators to assign a priority level to traffic based on the Uniform Resource Locator (URL) from which the traffic originates.

What is the role of BranchCache? | Networking


BranchCache enables updated content from file and Web servers on a Wide Area Network (WAN) to be cached on computers at a local branch office, improving application response time and reducing WAN traffic.

What is the role of VPN Reconnect? | Networking


VPN Reconnect automatically re-establishes a VPN connection as soon as Internet connectivity is restored, saving users from re-entering their credentials and recreating the VPN connection.

What is the role of DirectAccess? | Networking


DirectAccess enables users to access an enterprise network without the extra step of initiating a Virtual Private Network (VPN) connection.

What are the new networking features in Windows 2008 R2? | Networking


Following are the new networking features in Windows 2008 R2:
1. DirectAccess
2. VPN Reconnect
3. BranchCache
4. URL-based Quality of Service (QoS)
5. Mobile broadband device support
6. Multiple active firewall profiles
7. NDF, Network Tracing, and Netsh Trace

What are the different service packs available for Windows 2003 and Windows 2008?


For both Windows 2003 and Windows 2008, available service packs are SP1 and SP2.

What do you mean by client and server? | Networking


Client and server are two different machines (physical or virtual) connected in such a manner that whenever a client posts some request to a server, the server provides an appropriate response to the client.

What is device driver? | Networking

Device driver Is a software component that provides an interface between the hardware of a computer and its operating system. Hardware, such as keyboards, controllers, and graphics cards, requires device drivers so that the operating system can detect the devices and handle them effectively and efficiently.

What is NetBIOS? | Networking

NetBIOS stands for Network Basic Input / Output System. It is an application interface, which operates at the session layer. It enables communication between applications with NetBIOS compliant protocol. NetBIOS applications can be supported over Transmission Control Protocol/Internet Protocol (TCP/IP) and IPX/SPX.

Where is IPX/SPX used? | Networking

IPX/SPX stands for Internetwork Packet Exchange/Sequenced Packet Exchange. It is used in the Netware environment. IPX runs at the network layer of the Open Systems Interconnection (OSI) model; whereas, SPX runs at the transport layer of the OSI model.

What is NetBIOS Extended User Interface (NetBEUI) and is it routable? | Networking

 NetBEUI is designed for peer-to-peer network and is a high speed protocol used on small networks. It provides a good recovery and error protection.
No, it is not routable.

What is network binding? | Networking

A network binding binds a protocol to an adapter to carry traffic using that protocol.
 

What is Fiber Distributed Data Interface (FDDI)? | Networking

FDDI is a token-passing dual ring fiber optic LAN specification. It supports higher transmission speeds across larger distances of around 2 km (1.3 miles) between two stations.
 

What is the maximum network length of 10Base2 and 10Base5? | Networking

The maximum network length of 10Base2 is 185 m for each segment and can be extended up to five segments.
The maximum network length of 10Base5 is 500m for each segment and can be extended up to five segments.

How many stations can be connected to 10Base2, lOBaseT, and 10Base5? | Networking

 Maximum stations that can be connected to 10Base2 are 30 stations.
Maximum stations that can be connected to lOBaseT are 1024 stations per network.
Maximum stations that can be connected to 10Base5 are 100 nodes per segment and maximum network length of 10Base5 is five segments, that is, approximately 2500 m or 8200 ft.

List the reasons of transmission failure. | Networking

Transmission failure can be caused by the following reasons:
1.    Bad cabling
2.    Improper termination
3.    Collisions
4.    Improper cable length.

What is token passing? | Networking

A token is a small frame, which is passed from one node to another in a token ring network. If a node has data to send, it must wait until it receives a token. After the token is received by the node, it seizes the token, marks it as used, and attaches the data. The frame is then addressed to the destination node and the node continues passing the data around the ring until it arrives at the destination node. The destination node copies the data and marks the frame as received. When the sender node receives the frame, it implies that the data is successfully delivered. The sender node then frees the token to be used by another node.

What is CSMA/CD? | Networking

 CSMA/CD is a layer 2 access method in which if a transmitting data station detects another signal while transmitting a frame, it stops transmitting the frame. Instead of the frame, it transmits a jam signal, and then waits for a random time interval before trying to send the frame again.

Multiple devices cannot communicate on the network simultaneously; therefore, what type of method must be used to allow one device to access network media at a time?

Carrier Sense Multiple Access / Collision Detection (CSMA/CD) and token passing.

What is hub? | Networking

A hub is a device that connects multiple user stations, each through a dedicated cable.

What is repeater? | Networking

A repeater is a device used to interconnect the media segments of an extended network. It enables a series of cable segments to be treated as a single cable. Repeaters receive signals from one network segment and amplify, retime, and retransmit those signals to another network segment to prevent signal deterioration caused by long cable lengths and large numbers of connected devices.
 

What devices are commonly used in LAN networks? Networking

The commonly used devices in a LAN network are repeaters, hubs, LAN extenders, bridges, LAN switches, and routers.

Explain tree topology. | Networking

A tree topology is a LAN architecture that is similar to the bus topology but with multiple nodes. It can also be defined as a combination of the bus and star topologies.

What types of topologies are commonly used for Local Area Network (LAN) and Wide Area Network (WAN)? | Networking

 Bus, ring, star, mesh, tree, and cellular topologies are used for LANs; whereas, point-to-point, multipoint, mesh, and cloud topologies are used for WANs.

What is the length of USB cable? | Networking

Normally, USB cables are limited to 5m; however, hubs can be used as an active USB repeater to extend the cable length for up to 5m at a time.

How many devices can be connected to one USB port? | Networking

USB hubs can generally extend a USB network to a maximum of 127 ports.

What type of connector is used to connect a modem to wall jack? | Networking

  RJ-11 is used to connect a modem to wall jack.

What is the use of USB connector? | Networking

 USB is an external hardware interface and communications standard that is utilized for connecting varied peripherals to a computer, such as mouse, external drive, digital cameras, memory sticks, and gaming peripherals.

What is the use of RJ-45 connector? | Networking

The FU-45 connector is an industry standard for Ethernet and Fast Ethernet networking. It is used to attach short cable (patch cable) to connect the computer to wall jack.

What is the use of RJ-11 connector? | Networking

The RJ-11 connector is generally used to connect standard telephone cord.
 

What are the different types of connectors? | Networking

The different types of connectors are DB-9, DB-25, RJ-11, RJ- 45, Bayonet Neill-Concelman (BNC), PS2/MINI-DIN, and Universal Serial Bus (USB).

What connectors are used in the Ethernet and wireless network cards? | Networking

   Ethernet network cards use the RJ-45 connector; whereas, wireless network cards usually have no external connections other than an antenna jack.

List the different types of network card. | Networking

   The different types of network card are as follows:
1.    Ethernet card
2.    Wireless network card
3.    Token Ring network card.

What is a network card? | Networking

  A network card Is an expansion card installed in a computer that enables the computer to be physically connected to a network.

Networking Interview Questions and Answers PDF free Download

1. How to you keep yourself updated on network security -or- Where do you get updates on security?
2. If you need to encrypt and compress data for transmission, how would you achieve it?
3. What factors would you consider before deploying a web intrusion detection system?
4. What is Cross site scripting?
5. How does the HTTP handle state?
6. In context of public key encryption, if you are using both signature and encryption features, what key will you use for encryption and which one will you use for signing?
7. What type of network do you use at home?
8. What is Cross Site Request Forgery and how to defend against it?
9. Name the port used by PING.
10. Security Life Cycle.
11. Define the meaning of an Authentication.
12. What is the sense of a fingerprint?
13. What a security mean in your sense?
14. What is a Password?
15. What is a Smart Card or Chip Card or Integrated Circuit Card (ICC)?
16. Finally, who is a hacker?
17. What are the types of LAN cables used? What is a cross cable? 
18. What is IPCONFIG command? Why it is used?
19. What is BSOD? What do you do when you get blue screen in a computer? How do you troubleshoot it?
20. What is RIS? What is Imaging/ghosting?

How do I interface to C++ objects from Python? | Python

Depending on your requirements, there are many approaches. To do this manually, begin by reading the "Extending and Embedding" document. Realize that for the Python run-time system, there isn't a whole lot of difference between C and C++ -- so the strategy of building a new Python type around a C structure (pointer) type will also work for C++ objects.

How do I access a module written in Python from C? | Python

You can get a pointer to the module object as follows:
module = PyImport_ImportModule("");
If the module hasn't been imported yet (i.e. it is not yet present in sys.modules), this initializes the module; otherwise it simply returns the value of sys.modules[""]. Note that it doesn't enter the module into any namespace -- it only ensures it has been initialized and is stored in sys.modules.
You can then access the module's attributes (i.e. any name defined in the module) as follows: attr = PyObject_GetAttrString(module, "");
Calling PyObject_SetAttrString() to assign to variables in the module also works.

How do I extract C values from a Python object? | Python

That depends on the object's type. If it's a tuple, PyTupleSize(o) returns its length and
PyTuple_GetItem(o, i) returns its i'th item. Lists have similar functions, PyListSize(o) and PyList_GetItem(o, i).
For strings, PyString_Size(o) returns its length and PyString_AsString(o) a pointer to its value. Note that Python strings may contain null bytes so C's strlen() should not be used.
To test the type of an object, first make sure it isn't NULL, and then use PyString_Check(o), PyTuple_Check(o), PyList_Check(o), etc.

There is also a high-level API to Python objects which is provided by the so-called 'abstract' interface -- read Include/abstract.h for further details. It allows interfacing with any kind of Python sequence using calls like PySequence_Length(), PySequence_GetItem(), etc.) as well as many other useful protocols.

How can I evaluate an arbitrary Python expression from C? | Python

Call the function PyRun_String() from the previous question with the start symbol Py_eval_input; it parses an expression, evaluates it and returns its value.

Can I create my own functions in C++? | Python

Yes, using the C compatibility features found in C++. Place extern "C" { ... } around the Python include files and put extern "C" before each function that is going to be called by the Python interpreter. Global or static C++ objects with constructors are probably not a good idea.

How can I execute arbitrary Python statements from C? | Python

The highest-level function to do this is PyRun_SimpleString() which takes a single string argument to be executed in the context of the module __main__ and returns 0 for success and -1 when an exception occurred (including SyntaxError). If you want more control, use PyRun_String(); see the source for PyRun_SimpleString() in Python/pythonrun.c.

Can I create my own functions in C? | Python

Yes, you can create built-in modules containing functions, variables, exceptions and even new types in C.

How do I generate random numbers in Python? | Python

The standard module random implements a random number generator. Usage is simple:
import random
random.random()
This returns a random floating point number in the range [0, 1).

How do I avoid blocking in the connect() method of a socket? | Python

The select module is commonly used to help with asynchronous I/O on sockets.

Are there any interfaces to database packages in Python? | Python

Yes.
Python 2.3 includes the bsddb package which provides an interface to the BerkeleyDB library.
Interfaces to disk-based hashes such as DBM and GDBM are also included with standard Python.

Why don't my signal handlers work? | Python

The most common problem is that the signal handler is declared with the wrong argument list. It is called as:
handler(signum, frame)
so it should be declared with two arguments: def handler(signum, frame).

How do I make a Python script executable on Unix? | Python

You need to do two things: the script file's mode must be executable and the first line must begin with #! followed by the path of the Python interpreter.
The first is done by executing chmod +x scriptfile or perhaps chmod 755 scriptfile.
The second can be done in a number of ways. The most straightforward way is to write
#!/usr/local/bin/python
as the very first line of your file, using the pathname for where the Python interpreter is installed on your platform.
If you would like the script to be independent of where the Python interpreter lives, you can use the "env" program. Almost all Unix variants support the following, assuming the python interpreter is in a directory on the user's $PATH:
#! /usr/bin/env python
Don't do this for CGI scripts. The $PATH variable for CGI scripts is often very minimal, so you need to use the actual absolute pathname of the interpreter.
Occasionally, a user's environment is so full that the /usr/bin/env program fails; or there's no env program at all. In that case, you can try the following hack (due to Alex Rezinsky):
#! /bin/sh
""":"
exec python $0 ${1+"$@"}
"""
The minor disadvantage is that this defines the script's __doc__ string. However, you can fix that by adding
__doc__ = """...Whatever..."""

Where is the math.py (socket.py, regex.py, etc.) source file? | Python

There are (at least) three kinds of modules in Python:
1. modules written in Python (.py);
2. modules written in C and dynamically loaded (.dll, .pyd, .so, .sl, etc);
3. modules written in C and linked with the interpreter; to get a list of these, type: import sys print sys.builtin_module_names

How do I find the current module name? | Python

A module can find out its own module name by looking at the predefined global variable __name__. If this has the value '__main__', the program is running as a script. Many modules that are usually used by importing them also provide a command-line interface or a self-test, and only execute this code after checking __name__:
def main():
print 'Running test...'
if __name__ == '__main__':
main()
__import__('x.y.z') returns
Try:
__import__('x.y.z').y.z
For more realistic situations, you may have to do something like m = __import__(s)
for i in s.split(".")[1:]: m = getattr(m, i)

How can I overload constructors (or methods) in Python? | Python

This answer actually applies to all methods, but the question usually comes up first in the context of constructors.
In C++ you'd write
class C {
C() { cout << "No arguments\n"; }
C(int i) { cout << "Argument is " << i << "\n"; }
}
in Python you have to write a single constructor that catches all cases using default arguments. For example:
class C:
def __init__(self, i=None): if i is None:
print "No arguments"
else:
print "Argument is", i
This is not entirely equivalent, but close enough in practice. You could also try a variable-length argument list, e.g.
def __init__(self, *args):
The same approach works for all method definitions.

How do I create static class data and static class methods? | Python

Static data (in the sense of C++ or Java) is easy; static methods (again in the sense of C++ or Java) are not supported directly.
For static data, simply define a class attribute. To assign a new value to the attribute, you have to explicitly use the class name in the assignment:
class C:
count = 0 # number of times C.__init__ called
def __init__(self):
C.count = C.count + 1
def getcount(self):
return C.count # or return self.count
c.count also refers to C.count for any c such that isinstance(c, C) holds, unless overridden by c itself or by some class on the base-class search path from c.__class__ back to C.
Caution: within a method of C, an assignment like self.count = 42 creates a new and unrelated instance vrbl named "count" in self's own dict. Rebinding of a class-static data name must always specify the class whether inside a method or not:
C.count = 314
Static methods are possible when you're using new-style classes:
class C:
def static(arg1, arg2, arg3): # No 'self' parameter!
static = staticmethod(static)
However, a far more straightforward way to get the effect of a static method is via a simple modulelevel function:
def getcount():
return C.count
If your code is structured so as to define one class (or tightly related class hierarchy) per module, this supplies the desired encapsulation.

How do I call a method defined in a base class from a derived class that overrides it? | Python

If you're using new-style classes, use the built-in super() function:
class Derived(Base):
def meth (self):
super(Derived, self).meth()
If you're using classic classes: For a class definition such as class Derived(Base): ... you can call method meth() defined in Base (or one of Base's base classes) as Base.meth(self, arguments...). Here, Base.meth is an unbound method, so you need to provide the self argument.

What is delegation? | Python

Delegation is an object oriented technique (also called a design pattern). Let's say you have an object x and want to change the behavior of just one of its methods. You can create a new class that provides a new implementation of the method you're interested in changing and delegates all other methods to the corresponding method of x.
Python programmers can easily implement delegation. For example, the following class implements a class that behaves like a file but converts all written data to uppercase:
class UpperOut:
def __init__(self, outfile): self.__outfile = outfile def write(self, s):
self.__outfile.write(s.upper())
def __getattr__(self, name):
return getattr(self.__outfile, name)
Here the UpperOut class redefines the write() method to convert the argument string to uppercase before calling the underlying self.__outfile.write() method. All other methods are delegated to the underlying self.__outfile object. The delegation is accomplished via the __getattr__ method; consult the language reference for more information about controlling attribute access.
Note that for more general cases delegation can get trickier. When attributes must be set as well as retrieved, the class must define a __settattr__ method too, and it must do so carefully. The basic implementation of __setattr__ is roughly equivalent to the following:
class X:
def __setattr__(self, name, value): self.__dict__[name] = value
Most __setattr__ implementations must modify self.__dict__ to store local state for self without causing an infinite recursion.

What is a method? | Python

A method is a function on some object x that you normally call as x.name(arguments...). Methods are defined as functions inside the class definition:
class C:
def meth (self, arg):
return arg*2 + self.attribute.

What is a class? | Python

A class is the particular object type created by executing a class statement. Class objects are used as templates to create instance objects, which embody both the data (attributes) and code (methods) specific to a datatype.
A class can be based on one or more other classes, called its base class(es). It then inherits the attributes and methods of its base classes. This allows an object model to be successively refined by inheritance.
You might have a generic Mailbox class that provides basic accessor methods for a mailbox, and subclasses such as MboxMailbox, MaildirMailbox, OutlookMailbox that handle various specific mailbox formats.

I want to do a complicated sort: can you do a Schwartzman Transform in Python? | Python

Yes, it's quite simple with list comprehensions.
The technique, attributed to Randal Schwartz of the Perl community, sorts the elements of a list by a metric which maps each element to its "sort value". To sort a list of strings by their uppercase values:
tmp1 = [ (x.upper(), x) for x in L ] # Schwartzman transform
tmp1.sort()
Usorted = [ x[1] for x in tmp1 ]
To sort by the integer value of a subfield extending from positions 10-15 in each string:
tmp2 = [ (int(s[10:15]), s) for s in L ] # Schwartzman transform tmp2.sort()
Isorted = [ x[1] for x in tmp2 ]
Note that Isorted may also be computed by
def intfield(s):
return int(s[10:15])
def Icmp(s1, s2):
return cmp(intfield(s1), intfield(s2))
Isorted = L[:]
Isorted.sort(Icmp)
but since this method calls intfield() many times for each element of L, it is slower than the Schwartzman Transform.

How do I apply a method to a sequence of objects? | Python

Use a list comprehension:
result = [obj.method() for obj in List]
More generically, you can try the following function:
def method_map(objects, method, arguments):
"""method_map([a,b], "meth", (1,2)) gives [a.meth(1,2), b.meth(1,2)]""" nobjects = len(objects)
methods = map(getattr, objects, [method]*nobjects)
return map(apply, methods, [arguments]*nobjects)

How do I create a multidimensional list? | Python

You probably tried to make a multidimensional array like this:
A = [[None] * 2] * 3
This looks correct if you print it:
>>> A
[[None, None], [None, None], [None, None]]
But when you assign a value, it shows up in multiple places:
>>> A[0][0] = 5
>>> A
[[5, None], [5, None], [5, None]]
The reason is that replicating a list with * doesn't create copies, it only creates references to the existing objects. The *3 creates a list containing 3 references to the same list of length two. Changes to one row will show in all rows, which is almost certainly not what you want.
The suggested approach is to create a list of the desired length first and then fill in each element with a newly created list:
A = [None]*3
for i in range(3):
A[i] = [None] * 2
This generates a list containing 3 different lists of length two. You can also use a list comprehension:
w,h = 2,3
A = [ [None]*w for i in range(h) ]
Or, you can use an extension that provides a matrix datatype; Numeric Python is the best known.

How do you remove duplicates from a list? | Python

If you don't mind reordering the list, sort it and then scan from the end of the list, deleting duplicates as
you go:
if List:
List.sort()
last = List[-1]
for i in range(len(List)-2, -1, -1): if last==List[i]: del List[i]
else: last=List[i]
If all elements of the list may be used as dictionary keys (i.e. they are all hash able) this is often faster
d = {}
for x in List: d[x]=x
List = d.values()
How do you make an array in Python?
Use a list:
["this", 1, "is", "an", "array"]
Lists are equivalent to C or Pascal arrays in their time complexity; the primary difference is that a Python list can contain objects of many different types.
The array module also provides methods for creating arrays of fixed types with compact representations, but they are slower to index than lists. Also note that the Numeric extensions and others define array-like structures with various characteristics as well.
To get Lisp-style linked lists, you can emulate cons cells using tuples: lisp_list = ("like", ("this", ("example", None) ) )
If mutability is desired, you could use lists instead of tuples. Here the analogue of lisp car is lisp_list[0] and the analogue of cdr is lisp_list[1]. Only do this if you're sure you really need to, because it's usually a lot slower than using Python lists.

How do I iterate over a sequence in reverse order? | Python

If it is a list, the fastest solution is
list.reverse()
try:
for x in list:
"do something with x"
finally:
list.reverse()
This has the disadvantage that while you are in the loop, the list is temporarily reversed. If you don't like this, you can make a copy. This appears expensive but is actually faster than other solutions:
rev = list[:]
rev.reverse()
for x in rev:

If it's not a list, a more general but slower solution is:
for i in range(len(sequence)-1, -1, -1): x = sequence[i]

A more elegant solution, is to define a class which acts as a sequence and yields the elements in reverse order (solution due to Steve Majewski):
class Rev:
def __init__(self, seq): self.forw = seq
def __len__(self):
return len(self.forw)
def __getitem__(self, i):
return self.forw[-(i + 1)]
You can now simply write:
for x in Rev(list):

Unfortunately, this solution is slowest of all, due to the method call overhead. With Python 2.3, you can use an extended slice syntax:
for x in sequence[::-1]:

What's a negative index? | Python

Python sequences are indexed with positive numbers and negative numbers. For positive numbers 0 is the first index 1 is the second index and so forth. For negative indices -1 is the last index and -2 is the penultimate (next to last) index and so forth. Think of seq[-n] as the same as seq[len(seq)-n].
Using negative indices can be very convenient. For example S[:-1] is all of the string except for its last character, which is useful for removing the trailing newline from a string.

How do I convert between tuples and lists? | Python

The function tuple(seq) converts any sequence (actually, any iterable) into a tuple with the same items in the same order.
For example, tuple([1, 2, 3]) yields (1, 2, 3) and tuple('abc') yields ('a', 'b', 'c'). If the argument is a tuple, it does not make a copy but returns the same object, so it is cheap to call tuple() when you aren't sure that an object is already a tuple.
The function list(seq) converts any sequence or iterable into a list with the same items in the same order. For example, list((1, 2, 3)) yields [1, 2, 3] and list('abc') yields ['a', 'b', 'c']. If the argument is a list, it makes a copy just like seq[:] would.

Is there a scanf() or sscanf() equivalent? | Python

Not as such.
For simple input parsing, the easiest approach is usually to split the line into whitespace-delimited words using the split() method of string objects and then convert decimal strings to numeric values using int() or float(). split() supports an optional "sep" parameter which is useful if the line uses something other than whitespace as a separator.
For more complicated input parsing, regular expressions more powerful than C's sscanf() and better suited for the task. 1.3.9 What does 'UnicodeError: ASCII [decoding,encoding] error: ordinal not in range(128)' mean?
This error indicates that your Python installation can handle only 7-bit ASCII strings. There are a couple ways to fix or work around the problem.
If your programs must handle data in arbitrary character set encodings, the environment the application runs in will generally identify the encoding of the data it is handing you. You need to convert the input to Unicode data using that encoding. For example, a program that handles email or web input will typically find character set encoding information in Content-Type headers. This can then be used to properly convert input data to Unicode. Assuming the string referred to by value is encoded as UTF-8:
value = unicode(value, "utf-8")
will return a Unicode object. If the data is not correctly encoded as UTF-8, the above call will raise a UnicodeError exception.
If you only want strings converted to Unicode which have non-ASCII data, you can try converting them first assuming an ASCII encoding, and then generate Unicode objects if that fails:
try:
x = unicode(value, "ascii") except UnicodeError:
value = unicode(value, "utf-8")
else:
# value was valid ASCII data
pass
It's possible to set a default encoding in a file called sitecustomize.py that's part of the Python library. However, this isn't recommended because changing the Python-wide default encoding may cause thirdparty extension modules to fail.
Note that on Windows, there is an encoding known as "mbcs", which uses an encoding specific to your current locale. In many cases, and particularly when working with COM, this may be an appropriate default encoding to use.

How do I use strings to call functions/methods? | Python

There are various techniques.
* The best is to use a dictionary that maps strings to functions. The primary advantage of this technique is that the strings do not need to match the names of the functions. This is also the primary technique used to emulate a case construct:
def a():
pass
def b():
pass
dispatch = {'go': a, 'stop': b} # Note lack of parens for funcs
dispatch[get_input()]() # Note trailing parens to call function
*
Use the built-in function getattr():
import foo
getattr(foo, 'bar')()
Note that getattr() works on any object, including classes, class instances, modules, and so on. This is used in several places in the standard library, like this:
class Foo:
def do_foo(self):
def do_bar(self):
f = getattr(foo_instance, 'do_' + opname)
f()
*
Use locals() or eval() to resolve the function name:
def myFunc():
print "hello"
fname = "myFunc"
f = locals()[fname]
f()
f = eval(fname)
f()
Note: Using eval() is slow and dangerous. If you don't have absolute control over the contents of the string, someone could pass a string that resulted in an arbitrary function being executed.
Is there an equivalent to Perl's chomp() for removing trailing newlines from strings?
Starting with Python 2.2, you can use S.rstrip("\r\n") to remove all occurences of any line terminator
from the end of the string S without removing other trailing whitespace. If the string S represents more
than one line, with several empty lines at the end, the line terminators for all the blank lines will be
removed:
>>> lines = ("line 1 \r\n"
... "\r\n"
... "\r\n")
>>> lines.rstrip("\n\r")
"line 1 "
Since this is typically only desired when reading text one line at a time, using S.rstrip() this way works
well.
For older versions of Python, There are two partial substitutes:
* If you want to remove all trailing whitespace, use the rstrip() method of string objects. This removes all trailing whitespace, not just a single newline.
* Otherwise, if there is only one line in the string S, use S.splitlines()[0].
Is there a scanf() or sscanf() equivalent?
Not as such.
For simple input parsing, the easiest approach is usually to split the line into whitespace-delimited words using the split() method of string objects and then convert decimal strings to numeric values using int() or float(). split() supports an optional "sep" parameter which is useful if the line uses something other than whitespace as a separator.
For more complicated input parsing, regular expressions more powerful than C's sscanf() and better suited for the task.

How do I modify a string in place? | Python

You can't, because strings are immutable. If you need an object with this ability, try converting the string to a list or use the array module:
>>> s = "Hello, world" >>> a = list(s)
>>>print a
['H', 'e', 'l', 'l', 'o', ',', ' ', 'w', 'o', 'r', 'l', 'd'] >>> a[7:] = list("there!")
>>>''.join(a)
'Hello, there!'
>>> import array
>>> a = array.array('c', s) >>> print a
array('c', 'Hello, world')
>>> a[0] = 'y' ; print a
array('c', 'yello world')
>>> a.tostring()
'yello, world'

How do I convert a number to a string? | Python

To convert, e.g., the number 144 to the string '144', use the built-in function str(). If you want a hexadecimal or octal representation, use the built-in functions hex() or oct(). For fancy formatting, use the % operator on strings, e.g. "%04d" % 144 yields '0144' and "%.3f" % (1/3.0) yields '0.333'. See the library reference manual for details.

How can my code discover the name of an object? | Python

Generally speaking, it can't, because objects don't really have names. Essentially, assignment always binds a name to a value; The same is true of def and class statements, but in that case the value is a callable. Consider the following code:
class A:
pass
B = A
a = B()
b = a
print b
<__main__.A instance at 016D07CC>
print a
<__main__.A instance at 016D07CC>
Arguably the class has a name: even though it is bound to two names and invoked through the name B the created instance is still reported as an instance of class A. However, it is impossible to say whether the instance's name is a or b, since both names are bound to the same value.
Generally speaking it should not be necessary for your code to "know the names" of particular values. Unless you are deliberately writing introspective programs, this is usually an indication that a change of approach might be beneficial.
In comp.lang.python, Fredrik Lundh once gave an excellent analogy in answer to this question:
The same way as you get the name of that cat you found on your porch: the cat (object) itself cannot tell you its name, and it doesn't really care -- so the only way to find out what it's called is to ask all your neighbours (namespaces) if it's their cat (object)
....and don't be surprised if you'll find that it's known by many names, or no name at all!

Is there an equivalent of C's "?:" ternary operator? | Python

No.

How do I convert a string to a number? | Python

For integers, use the built-in int() type constructor, e.g. int('144') == 144. Similarly, float() converts to floating-point, e.g. float('144') == 144.0.
By default, these interpret the number as decimal, so that int('0144') == 144 and int('0x144') raises ValueError. int(string, base) takes the base to convert from as a second optional argument, so int('0x144', 16) == 324. If the base is specified as 0, the number is interpreted using Python's rules: a leading '0' indicates octal, and '0x' indicates a hex number.
Do not use the built-in function eval() if all you need is to convert strings to numbers. eval() will be significantly slower and it presents a security risk: someone could pass you a Python expression that might have unwanted side effects. For example, someone could pass __import__('os').system("rm -rf $HOME") which would erase your home directory.
eval() also has the effect of interpreting numbers as Python expressions, so that e.g. eval('09') gives a syntax error because Python regards numbers starting with '0' as octal (base 8).

How can I find the methods or attributes of an object? | Python

For an instance x of a user-defined class, dir(x) returns an alphabetized list of the names containing the instance attributes and methods and attributes defined by its class.

How do I copy an object in Python? | Python

In general, try copy.copy() or copy.deepcopy() for the general case. Not all objects can be copied, but most can.
Some objects can be copied more easily. Dictionaries have a copy() method: newdict = olddict.copy()
Sequences can be copied by slicing: new_l = l[:]

How do you make a higher order function in Python? | Python

You have two choices: you can use nested scopes or you can use callable objects. For example,
suppose you wanted to define linear(a,b) which returns a function f(x) that computes the value a*x+b. Using nested scopes:
def linear(a,b):
def result(x):
return a*x + b
return result
Or using a callable object:
class linear:
def __init__(self, a, b):
self.a, self.b = a,b
def __call__(self, x):
return self.a * x + self.b
In both cases:
taxes = linear(0.3,2)
gives a callable object where taxes(10e6) == 0.3 * 10e6 + 2.
The callable object approach has the disadvantage that it is a bit slower and results in slightly longer code. However, note that a collection of callables can share their signature via inheritance:
class exponential(linear):
# __init__ inherited
def __call__(self, x):
return self.a * (x ** self.b)
Object can encapsulate state for several methods:
class counter:
value = 0
def set(self, x): self.value = x
def up(self): self.value=self.value+1
def down(self): self.value=self.value-1
count = counter()
inc, dec, reset = count.up, count.down, count.set
Here inc(), dec() and reset() act like functions which share the same counting variable.

How can I pass optional or keyword parameters from one function to another? | Python

Collect the arguments using the * and ** specifier in the function's parameter list; this gives you the positional arguments as a tuple and the keyword arguments as a dictionary. You can then pass these arguments when calling another function by using * and **:
def f(x, *tup, **kwargs):
kwargs['width']='14.3c'
g(x, *tup, **kwargs)
In the unlikely case that you care about Python versions older than 2.0, use 'apply': def f(x, *tup, **kwargs):
kwargs['width']='14.3c'
apply(g, (x,)+tup, kwargs)

How do I share global variables across modules? |

The canonical way to share information across modules within a single program is to create a special module (often called config or cfg). Just import the config module in all modules of your application; the module then becomes available as a global name. Because there is only one instance of each module, any changes made to the module object get reflected everywhere.
For example:
config.py:
x = 0 # Default value of the 'x' configuration setting
mod.py:
import config
config.x = 1
main.py:
import config
import mod
print config.x
Note that using a module is also the basis for implementing the Singleton design pattern, for the same reason.

What are the rules for local and global variables in Python? | Python

In Python, variables that are only referenced inside a function are implicitly global. If a variable is assigned a new value anywhere within the function's body, it's assumed to be a local. If a variable is ever assigned a new value inside the function, the variable is implicitly local, and you need to explicitly declare it as 'global'.
Though a bit surprising at first, a moment's consideration explains this. On one hand, requiring global for assigned variables provides a bar against unintended side-effects. On the other hand, if global was required for all global references, you'd be using global all the time. You'd have to declare as global every reference to a builtin function or to a component of an imported module. This clutter would defeat the usefulness of the global declaration for identifying side-effects.

How do you set a global variable in a function?

x = 1 # make a global
def f():
print x # try to print the global
for j in range(100):
if q>3:
x=4
Any variable assigned in a function is local to that function. unless it is specifically declared global. Since a value is bound to x as the last statement of the function body, the compiler assumes that x is local. Consequently the print x attempts to print an uninitialized local variable and will trigger a NameError.
The solution is to insert an explicit global declaration at the start of the function:
def f():
global x
print x # try to print the global
for j in range(100):
if q>3:
x=4
In this case, all references to x are interpreted as references to the x from the module namespace.

Is there a tool to help find bugs or perform static analysis? | Python

Yes.
PyChecker is a static analysis tool that finds bugs in Python source code and warns about code complexity and style.
Pylint is another tool that checks if a module satisfies a coding standard, and also makes it possible to write plug-ins to add a custom feature.

Why can't I use an assignment in an expression? | Python

Many people used to C or Perl complain that they want to use this C idiom:

while (line = readline(f)) {
...do something with line...
}
where in Python you're forced to write this:
while True:
line = f.readline() if not line:
break
...do something with line...

The reason for not allowing assignment in Python expressions is a common, hard-to-find bug in those other languages, caused by this construct:
if (x = 0) {
...error handling...
}
else {
...code that only works for nonzero x...
}
The error is a simple typo: x = 0, which assigns 0 to the variable x, was written while the comparison x == 0 is certainly what was intended.
Many alternatives have been proposed. Most are hacks that save some typing but use arbitrary or cryptic syntax or keywords, and fail the simple criterion for language change proposals: it should intuitively suggest the proper meaning to a human reader who has not yet been introduced to theconstruct.
An interesting phenomenon is that most experienced Python programmers recognize the "while True" idiom and don't seem to be missing the assignment in expression construct much; it's only newcomers who express a strong desire to add this to the language.
There's an alternative way of spelling this that seems attractive but is generally less robust than the "while True" solution:
line = f.readline() while line:
...do something with line... line = f.readline()
The problem with this is that if you change your mind about exactly how you get the next line (e.g. you
want to change it into sys.stdin.readline()) you have to remember to change two places in your program
-- the second occurrence is hidden at the bottom of the loop.
The best approach is to use iterators, making it possible to loop through objects using the for statement. For example, in the current version of Python file objects support the iterator protocol, so you can now write simply:
for line in f:
... do something with line...

What is Python? | Python

Python is an interpreted, interactive, object-oriented programming language. It incorporates modules, exceptions, dynamic typing, very high level dynamic data types, and classes. Python combines remarkable power with very clear syntax. It has interfaces to many system calls and libraries, as well as to various window systems, and is extensible in C or C++. It is also usable as an extension language for applications that need a programmable interface. Finally, Python is portable: it runs on many Unix variants, on the Mac, and on PCs under MS-DOS, Windows, Windows NT, and OS/2.

Python Interview Questions and Answers pdf free download

1) Explain about the programming language python?
2) Explain about the use of python for web programming?
3) State some programming language features of Python?
4) How is python interpreted?
5) Does python support object oriented scripting?
6) Describe about the libraries of Python?
7) State and explain about Strings?
8) Explain about classes in strings?
9) What is tuple?
10) Explain and statement about list?
11) Explain about the dictionary function in Python?
12) Explain about indexing and slicing operation in sequences?
13) Explain about raising error exceptions
14) What is a Lambda form?
15) Explain about assert statement?
16) Explain about repr function?
17) Explain about pickling and unpickling?
18) When do you use list vs. tuple vs. dictionary vs. set?
19) Why was the language called as Python?
20) Why cannot lambda forms in Python contain statements?

How do you view virtual memory statistics in Linux? | Oracle DBA

Virtual memory statistics are available through the vmstat command.

What is OERR? | Oracle DBA

OERR is a utility provided on the UNIX platform. It can be used to retrieve more information about an error message. This utility cannot work on Windows because it needs awk command to function; however, some workarounds are available to use this utility on Windows. It is a shell script that is saved in the $ORACLE_HOME/bin directory.
The syntax of the OERR utility is given as follows:
oerr <facility> <error> In the preceding syntax, the facility is the prefix to the error number that includes ORA, PLS, and EXP and the error is the actual error number returned by Oracle.
For example, if the database returns the ORA-12544 error, the following OERR utility would be executed to gain more information:

How do you automate starting and shutting down of databases in UNIX? | Oracle DBA

The /etc/oratab file contains an entry for each instance running on the server. The last character of that entry indicates whether the instance should be started and shut down automatically. You can set the value to Y for the SID to automatically start and shutdown the specific instance.

How do you find out the number of instances that are running on a server? | Oracle DBA

You can check the /etc/oratab file on a server to find out all the Oracle instances running on that server.

Give two UNIX kernel parameters that affect installation of Oracle. | Oracle DBA

The SHMMAX & SHMMNI UNIX kernel parameters affect the installation of Oracle.

List the major steps in installation of Oracle software on UNIX in brief. | Oracle DBA

Following are the steps in installation of Oracle software on UNIX:
i. Set up disk
ii. Set up kernel parameters
iii. Run the orainst command

How can you replace a string in a file in the vi editor? | Oracle DBA

A string in a file can be replaced by using the %s/<old string>/<new string>/g command.

What privileges are available on a UNIX directory? | Oracle DBA

Following privileges are available on the UNIX directory or file:
 Read —Allows you to view and list the directory or file contents.
 Write —Allows you to create, edit, and delete files and subdirectories in the directory.
 Execute —Gives you the previous read or write permissions. It also allows you to change into the directory and execute programs or shells from the directory.

What is the difference between a soft link and a hard link? | Oracle DBA

In the UNIX operating system, a filename can point either to the data of the file or another file. A soft link or symbolic link refers to a filename which points to another file while hard link refers to a filename that point to a file, which actually contains data. Note that UNIX considers directories as files only.

How do you execute a UNIX command that will continue running even after you log out? | Oracle DBA

You can use the nohup command to execute a UNIX command that will continue running even after you log out.
Normally when you log out, or your session terminates unexpectedly, the system kills all the processes you have started. In this case, you can use the nohup command, which allows you to run the command, process, or shell script that can continue running in the background after you log out from a shell.

How do you execute a UNIX command in the background? | Oracle DBA

A UNIX command can be executed in the background by ending the command with the & (ampersand) character; for example, gedit filename .

Give the command to list the files in the UNIX directory to list hidden files. | Oracle DBA

The Is -Itra command is used to list the files in the UNIX directory to list the hidden files.

Give the command to display space usage on the UNIX system. | Oracle DBA

The df -Ik command is used to display space usage on the UNIX system.

Where in the Oracle directory tree structure are audit traces placed? | Oracle DBA

Audit traces are placed in the ORACLEJHOME/rdbms/audit directory.

What is Optimal Flexible Architecture (OFA)? Why is it important to use OFA? | Oracle DBA

The OFA standard Is a set of configuration guidelines created to ensure fast and reliable Oracle databases that require little maintenance.
It is designed to enable the following:
i. Organize large amounts of complicated software and data on disk, to avoid device bottlenecks and poor performance
ii. Facilitate routine administrative tasks, such as software and data backup, which are often vulnerable to data corruption
iii. Facilitate switching between multiple Oracle databases
iv. Adequately manage and administer database growth
v. Help eliminate fragmentation of free space in the data dictionary, isolate other fragmentation, and minimize resource contention

What is the difference between logical standby database and physical standby database? | Oracle DBA

A physical standby database is physically same as production database, It has same file structure as production database while logical database can have different physical structure as compared to production database.
A physical standby is available only when production database is not available while logical standby can be available for reporting in parallel to production database.

How can you find out whether a database is primary or standby? | Oracle DBA

You can query the v$database view. The database_role column provides the relevant information.

What is the maximum number of standby databases that can be associated with a production database? | Oracle DBA

A production database can have maximum of nine standby databases.

What is role transition and when does it happen? | Oracle DBA

Role transition is the change of role between primary and standby databases.
It can happen in the following two cases:
i.  Switchover, where primary database is switched to standby database and standby database is switched to primary database
ii. Failover, where a standby database can be used as a disaster recovery solution in case of a failure in the primary database

Is there any difference in the data changes in primary and secondary database? | Oracle DBA

The primary and standby databases can be completely synchronized or partially synchronized in terms of data based on the synchronization mode set for data guard, which offers
i.Maximum protection mode —Specifies that a data change on primary database is acknowledged only when it is available to standby database at least in the form of redo log information. In this mode, primary database shuts down if at least one standby database cannot be updated.'
ii.Maximum availability mode —Specifies that a transaction cannot be committed unless redo logs of at least one standby database are completely synchronized with primary database. However, this mode is more tolerant in terms of fault in updating standby database. It allows the primary database to function temporarily in maximum performance mode until such error is resolved and gaps are analyzed.
iii.Maximum performance mode —Allows slight delay in updating standby database; and therefore, offers certain performance gain. In this mode, transaction can be committed as long as the change is written to an online redo log of the primary database without waiting to transfer the redo log to the standby database.

What happens when standby database is not available? | Oracle DBA

If standby database is not available and the changes are made in primary database, then there will be a gap in the sequence of archive logs. The information about archive logs in these gaps can be found in the v$archive_gap view.

What are the services required on standby database? | Oracle DBA

Standby database requires Fetch Archive Log (FAL) client to request and fetch archive log files from primary database, remote file server to receive archived log files from primary database, archiver process to archive redo logs applied to standby database, and Managed Recovery Process (MRP) to apply redo logs to the standby database.

What are the services required on primary database? | Oracle DBA

Primary database requires log writer to generate log information, archiver process to generate archive log files, and fetch archive log server to request the archive log files from standby database.

Explain the architecture of data guard. | Oracle DBA

Data guard architecture includes the following components:
Primary database —Refers to the production database.
Standby database —Refers to a copy of primary or production database. Data guard architecture may have more than one standby database.
Log transport service —Manages transfer of archive log files from primary to standby database.
Network configuration —Refers to the network connection between primary and standby database. This connection is based on Oracle Net.
Log apply services —Applies archived logs to the standby database.
Role management services —Manages the role change between primary and standby databases.
Data guard broker —Manages data guard creation process and monitors the dataguard.

Why do you need to have data guard? What are the benefits of using data guard? | Oracle DBA

Data guard setup ensures that another database is available as a copy of production database at almost real time. As a result, we have higher protection for enterprise data and the new database is available very quickly without the need to actually restore and recover from backup. Therefore, data guard offers an excellent disaster recovery solution.

What is data guard? | Oracle DBA

Data guard Is a setup in which you can have one or more standby database available for a production database.

How can you identify locked object? | Oracle DBA

After you get ID1 from the v$lock view for locked object, you can query the dba_objects view to get the name of the object.

What are different types of locks? | Oracle DBA

There are two different types of locks, which are given as follows:
1. System locks — Held for a very brief period of time and controlled by Oracle.
2. User locks — created and managed using dbmsjock package.
Different types of user locks are given as follows:
i. The UL lock— Defined with the dbmsjock package.
ii. The TXlock—Acquired once for every transaction. It is a row transaction lock.
iii. The TMlock—Acquired once for each object, which is being changed. It is a DML lock. The ID1 column identifies the object being modified.

How would you determine what sessions are connected and what resources they are waiting for? | Oracle DBA

You can use the V$SESSION and V$SESSION_WAIT dynamic performance views.

How can you get more details about the blocking session? | Oracle DBA

You can use the v$session or gv$session view in Real Application Clusters (RAC) environment to get the session information.

What do the db_file_sequential_read and db_file_scattered_read events indicate? | Oracle DBA

The db_fjle_sequential_read event generally indicates index usage and shows an access by rowid while the db_file_scattered_read event indicates full table scan.
A single block is read at one time in the db_file_sequential_read event while multiple blocks are read parallel in the db_file_scattered_read event.

Describe the Oracle Wait Interface. | Oracle DBA

The Oracle Wait Interface is the set of data dictionary tables that store information about wait events. Oracle offers multiple views to give information about wait events, such as v$system_event and v$session_event.
You can get the information about wait events for the database or a specific session from these views and find out the event, which seems too high. Upon further analysis, you can determine the cause of such events and then resolve the issue.

How can you find out if a session is blocking another? | oracle DBA

You can use the dba_blockers and dba_waiters views.
However, these views only provide information on all the blocking sessions and the waiting sessions.

What do you understand by db file scattered read? | Oracle DBA

Db file scattered read indicates a scatter read into multiple discontinuous locations. It generally indicates full table scan and that multiple blocks are being read into memory. Such
reads are called scattered read calls, because the blocks are scattered throughout memory.

What is db file sequential read wait event? | Oracle DBA

The db file sequential read wait event performs single-block read operations against indexes, tables, control files, rollback segments, and data file headers. It has three parameters: file#, first block#, and block count.

What is a lock? | Oracle DBA

Lock is a mechanism provided by Oracle to reserve a database object so that different sessions do not interfere in each other's work.
Locking helps in ensuring data consistency and maintaining database objects in usable state in multi-user environment. However, it can cause one session to block another.

What are dynamic performance views? Who has the access to these views? | Oracle DBA

Dynamic performance views are also called V$ views. These views provide information about the sessions.
Any Oracle user can get information from dynamic performance views if the user has the select any table privilege. This privilege is generally granted through the SELECT_CATALOG_ROLE role.

How can you monitor performance of the database pro- actively? | Oracle DBA

Several tools, such as Oracle Enterprise Manager, and utilities from third party are available for monitoring database performance. However, all these tools or utilities depend on statistics gathered by Oracle, which are available through dynamic performance views.

Which utility can you use to make trace file more readable? | Oracle DBA

You can use the TKPROF utility to make user process trace file more readable. TKPROF converts raw information into formatted output in user process trace file.

Which trace file is used for performance tuning and why? | Oracle DBA

User process trace file is used for performance tuning because it contains information about execution plan and resource consumption. This information can be used for performance tuning.

What is a user process trace file? | Oracle DBA

A user process trace file is a trace file that is produced by user session. However, this is an optional file, which is generated if the user wants to generate the file. This file is generated when the value of SQL_TRACE parameter is set to TRUE for a session.
This parameter can be set at database, instance, or session level. If it is set at instance level, trace file will be generated for all the connected sessions. If it is set at session level, trace file will be generated only for the specified session.
The location of user process trace file is specified in the USER_DUMP_DEST parameter.
The information in user process trace file is generally used for trouble shooting.

What are the background trace files? | Oracle DBA

Background trace files are associated with background processes and are generated when certain background process experiences an error. The information in background trace files is generally used for trouble shooting.
These files are located in the directory specified in the BACKGROUND_DUMP_DIRECTORY parameter.

Which tools are available to monitor performance? | Oracle DBA

Oracle offers Oracle Enterprise Manager (OEM) to monitor performance.
OEM can also be used to startup and shutdown the instance. In addition, it can be used to manage database in general.

What is the use of ALERT log file? Where can you find the ALERT log file? | Oracle DBA

The ALERT log is a log file that records database-wide events.
The information in the ALERT log file is generally used for trouble shooting.
Following events are recorded in the ALERT log file:
i. Database shutdown and startup information
ii. All non-default parameters
iii. Oracle internal (ORA-600) errors
iv. Information about a modified control file
v. At log switch
The location of ALERT log file is specified in the BACKGROUND_DUMP_DEST parameter.

Name a few places you will look to get more details on a performance issue.

Oracle records the information about different kind of errors and the processes in the files, such as ALERT log, user process trace files, and background process trace files.

What procedures can you use to register with an AQ? | Oracle DBA

The user of an AQ is called a subscriber, which can be added through the add_subscriber procedure. It can be altered using the alter_subscriber procedure and removed using the drop_subscriber procedure of the dbms_aqadm package.
Oracle also provides procedures to schedule propagation of messages in an AQ. This procedure is called schedule_propagation. It can be unscheduled using the unscheduled_propagation procedure.

How can you grant privileges on AQ to other users? | Oracle DBA

You qannot grant privileges on AQ by using a grant statement similar to other Oracle objects. You can use the following procedures:
i. grant_system_privilege — Grants AQ system privileges
ii. revoke_system_privilege —Revokes AQ system privileges
iii. grant_queue_privilege —Grants privileges on AQ
iv. revoke_queue_privilege —Revokes privileges on AQ.

How can you create an Advanced Queuing (AQ)? | Oracle DBA

Oracle provides the dbms_aqadm package to create an advanced queue. This package can be used to create, alter and drop AQ.
The procedures that provide these functions are given as follows:
? Create_queue_table
n A!ter_queue__table
? Drop_queue_tabie
? Createjqueue
? Alter__queue
? Drop_queue
? Start^queue
? Stop_queue.

List some of the procedures provided by the dbms_aq package. | Oracle DBA

Some of the procedures provided by the dbms_aq package! are enqueue, dequeue, register, and unregister.

How can you process messages in order asynchronously? | Oracle DBA

Oracle provides a package called dbms_aq package to queue the messages, which can be consumed by another session or application in order.

When does an alert gets signaled? | Oracle DBA

Alerts are transaction-based. Whenever, a transaction causing event of interest commits, the alert is signaled.

How can a session indicate its interest in receiving alerts? | Iracle DBA

A session can register itself for a specific type of alert or all alerts by using the register procedure. Such sessions are called waiting sessions.

Does Oracle support asynchronous notification? | Oracle DBA

Oracle supports asynchronous notification using the dbms_alert package.

How can you execute queries using the dbms_sql package? | Oracle DBA

You must perform the following steps if you are using dynamic Structured Query Language(SQL) to process a query:
i. Specify the variables that are to receive the values returned by the SELECT statement by calling the DEFINE_COLUMN,DEFINE_COLUMN_LONG, or DEFINE_ARRAY procedures.
ii. Run the SELECT statement by calling the EXECUTE function.
iii. Call the FETCH_ROWS (or EXECUTE_AND_FETCH)
iv. function to retrieve the rows that satisfied the query.
iv. Call the COLLIMN_VALUE or COLUMN_VALUE_LONG procedure to determine the value of a column retrieved by the FETCH_ROWS function for the query. If you use anonymous blocks containing calls to PL/SQL procedures, then you must call the VARIABLE_VALUE procedure to retrieve the values assigned to the output variables of these procedures.

How can you use the dbms_sql package to execute the DMLs dynamically? | Oracle DBA

Following statements show the use of the dbms_sql package to execute the DMLs dynamically:
i. dbms_sql.open_cursor;
ii. dbms_sql.parse(c, X', dbms_sql.native);
iii. dbms_sql.bind_variable(c, T, );
iv. n := dbms_sql.execute(c);
v. dbms_sql.close_cursor(c);

Can you get information about a specific rowid of a table using any Oracle supplied package? | Oracle DBA

Yes, Oracle provides a package called dbms_rowid. It is very useful in getting information about specific rows in a table.
Some of the procedures supplied by this package are given as follows:
i. rowid_create
ii. rowidjnfo
iii. rowid_object
iv. rowid_relative_fno
Note that rowid_create provides the rowid of an existing row by using information, such as file number and block. It cannot be used to create a new rowid for usage.

Does Oracle provide any package to find out fragmented data blocks? | Oracle DBA

You can use the dbms_space package to find out the fragmented data blocks. The space__usage procedure is quite helpful in getting the information on free space in each block in a segment. There are fsl_blocks, fs2_blocks, fs3_blocks, and fs4_blocks parameters, which give information about blocks that have 0- 25, 25-50, 50-75 and 75-100 percent free space, respectively.

Suppose you have developed a script to redefine a table after confirming that the table can be redefined; however, the redefinition process fails in the middle and further attempts show that it cannot be redefined as materialized view exists on the table. Why did this happen and how can you recover from the situation? | Oracle DBA

The reason for this is that materialized view was created during initial attempt to redefine the table.
You can perform the following steps to recover from the situation:
i. Select log_table from user_snapshot_logs;
ii. Select master, log_table from userjnviewjogs;
iii. Drop materialized view log on listed by second query
iv. Start redefinition process again.
The preceding steps can be replaced by abort_redef_table as well; although, the preceding process is faster.

How can you find out if a table can be redefined? | Oracle DBA

You can use the dbms_redefinition.can_redef_table procedure to determine if a table can be redefined.

How can you use the dbms„redefinition package? | Oracle DBA

You need to create an interim table in the desired format to use the dbms_redefinition package. Following are the three procedures to create an interim table:
i. Start_redef_tab/e— Initiates redefinition process
ii. Sync_interim_table — Keeps the interim table synchronized with the orginal table. This procedure is useful in minimizing the amount of synchronization needed to be done by the finish_redef_table procedure before completing the online redefinition. The Sync_interim_table procedure can be called between long running operations (such as create index) on the interim table to synchronize it with the data in the original table and speed up the subsequent operations.
iii. Finish_redef_table — Completes redefinition process. It switches the names of original table and interim table.
Prerequisite for using the dbms_redefinition package is to have sufficient free space for interim table in an appropriate tablespace to be able to switch the table names.

Can you redefine a table online? | Oracle DBA

Yes, you can use the dbms_redefinition package to redefine a table online.

Suppose you have developed scripts to redefine tables using the dbms_redefinition package and the user is granted privilege to execute the dbms_redefinition package but still the user gets insufficient privilege error when the script is executed. What is possible reason for the error?

The user needs following privileges in addition to execute the dbms_redefinition package to be able to use the scripts:
? Create any table
? Drop any table
? Select any table
? Alter any table
? Lock any table
The COPY_TABLE_DEPENDENTS procedure requires additional privileges, which are given as follows:
? Create any trigger
? Create any index

Is there any other way to read the information set by the dbms_application_info package? | Oracle DBA

The information set by the dbms„appiicationjnfo package is stored in the v$session and v$sqlarea views. You can get the information from these views.
You can also use the read_client_jnfo and read__module procedures to get the information.

Suppose you want to modify partitioning scheme of certain tables in a live database. How can you do that? | Oracle DBA

You can use the dbms_redefinition package to modify partitioning scheme of certain tables in a live database.

Name some of the procedures available in the dbms_appIication_info package. | Oracle DBA

The procedures available in the dbms_application_info package are setjnodule, sect_action, readjnodule, set_client_info, read_client_jnfo, and set_sessionJongops.

What is the use of recording information about current session? | Oracle DBA

The information is useful for tracing. You can set client information, module, or action information from different module of the application. At runtime, you can query different performance views to find out the action performed by application at that specific time.

How can you record information about current session? | OracleDBA

Oracle provides a package called dbms_applicationjnfo. This package can be used to set information about current session.

What is an interconnect network? | Oracle DBA

An interconnect network is a network between nodes of a cluster. It uses switches to ensure that only nodes can access this network. Generally, this is a high-speed connection.

Why do we need to store datafiles in shared storage in RAC environment? | Oracle DBA

A RAC setup is essentially a single database accessible through multiple nodes. Therefore, the datafiles in a RAC setup must be shared while the processes, which are used to manage or access those files, are available on each individual node.

What components are shared in RAC? | Oracle DBA

A RAC setup shares datafiles, control files, SP Files, redo log files; therefore, these files must be stored in the cluster-aware shared storage.

What is the use of RSMN? | Oracle DBA

RSMN stands for Remote Slave Monitor process. It creates slave processes on remote instance on behalf of master coordinating process running on another instance.

What is the use of RMSn? | Oracle DBA

RMSn are RAC Management processes. These processes manage RAC and create more resources whenever new instances are added to RAC.

What is the use of LCKO? | Oracle DBA

LCKO is lock process, which is used to manage requests for shared resources.

What is the use of LMS? | Oracle DBA

LMS stands for Lock Monitor Service. The primary job of this process is to transfer data blocks between cache of different nodes using high-speed interconnect. It is the most important and critical process for cache fusion. Each node has at least two LMS processes.

What is the use of LMD? | Oracle DBA

LMD stands for Lock Monitor Daemon process. This process is used for deadlock detection. It also manages remote resource and enqueue requests.

What is the use of Lock Monitor process? | Oracle DBA

It manages global resources and locks. It configures locks and resources wheneve an instance joins or leaves the cluster. It is also called Global Enqueue Service Monitor.

What is the use of GTXO-j? | Oracle DBA

GTX is a Global Transaction process, which provides transparent support for XA global transactions. The number of these processes is decided automatically based on the requirements.

What are the major RAC wait events? | Oracle DBA

The major RAC wait events are associated with buffer cache.
The most common wait events in RAC are gc cr request, which occurs when an instance tries to retrieve the data from the remote cache and gc buffer busy, which occurs when one instance finds the GC buffer busy.

What is cache fusion? | Oracle DBA

In a RAC setup, each node has its own memory; however, they share physical datafiles. As we know that data blocks are read into memory for updates or query in a single instance database. Similarly, in a RAC set up, a node reads a block from datafile when the node needs it. However, in RAC setting, the required block may be already available in the memory of another node and it is faster to read block from the memory of another block than from a datafile. Therefore, RAC provides a mechanism to read block from memory of one node to the memory of another node. This mechanism is called cache fusion.
Oracle uses high-speed interconnect to communicate between nodes. GES monitors and the Instance Enqueue process manages the cache fusion.

How does RAC ensures data consistency between two nodes? | Oracle DBA

RAC ensures data consistency between two nodes through cache fusion.

What is the use of Atomic Controlfile Memory Service (ACMS)? | Oracle DBA

ACMS ensures global updates to System Global Area (SGA) in a RAC set up.

What is the benefit of using Virtual IP (VIP)? | Oracle DBA

Whenever an application uses VIP to connect to a database, it can failover to another available node in case of a failure of one node. You need to use VIP as the host name in the Transparent Network Substrate (TNS) entry to use VIP.

What is Global Resource Directory (GRD}? | Oracle DBA

GRD is used by GES and GCS to maintain status of datafiles and cached blocks. This process provides required information for cache fusion and maintains data integrity.

List the background processes required for RAC. | Oracle DBA

The background processes required for RAC are given as follows:
i. ACMS— Atomic C ntrolfile to Memory Service
ii. GTXO-j— Global Transaction Process
iii. LMON— Global Enqueue Service Monitor
iv. LMD— Global Enqueue Service Daemon
v. LMS— Global Cache Service Process
vi. LCKO— Instance Enqueue Process
vii. RMSn — Oracle RAC Management Processes
viii. RSMN— Remote Slave Monitor.

Explain the software component of RAC. | Oracle DBA

In a RAC set up, each node has an Instance similar to a non RAC database. Each nstance in RAC has its own memory structures and background processes.
Oracle RAC instances use two processes: GES (Global Enqueue Service) and GCS (Global Cache Service) that enable cache fusion.

How is RAC different from non-RAC databases? | Oracle DBA

A non-RAC database has a single node while a RAC database has multiple (at least two) nodes. The nodes in a RAC set up share storage. RAC offers failover option while a non-RAC database does not offer failover option because it is based on a single node.

What is RAC? | Oracle DBA

Real Application cluster (RAC) is a clustering solution. It ensures high availability for database applications.
A RAC setup contains at least two nodes for a database. RAC provides high availability and load balancing through these nodes.

How can you set DML handler? | Oracle DBA

DML handler can be set by using the following statement:
Dbms_apply_adm.set_dml_handler(object_name/object_type, operation_name/error_handler,user_procedure,apply_db_link)

List some important Streams views. | Oracle DBA

Following are some important Streams views:
? DBA_STREAMS_TABLE_RULES
? DBA_APPLY_CONFLICT_COLUMNS
? GV$STREAMS_CAPTURE.

How can you find the setup of lob_assembly? | Oracle DBA

You can find the setup of lob_assembly by using the DBA_APPLY_DML_HANDLER view.

What is downstream capture? | Oracle DBA

Generally, capture process functions at source database.
However, if you want to save resources at the source database, you can set up another database for the capture process only. The feature, which allows you to move capture process to another database, is called downstream capture.

What is direct apply? | Oracle DBA

When the apply process applies the LCR directly at the target, it is called direct apply.

Why is additional supplemental logging needed? | Oracle DBA

Default logging process records the information about DML operations. Supplemental logging is required to identify the rows to be updated on each destination.

WhatisSYS-AnyData? | Oracle DBA

SYS.AnyData is a queue that can capture messages of type AnyData. This is a standard used in the Streams replication for storing LCRs. The reason for using this queue is that messages are wrapped into type AnyData before queuing.