IT Questions and Answers :)

Thursday, November 7, 2019

Which of the examples work in PowerShell version 3, but not in PowerShell version 2?

Which of the examples work in PowerShell version 3, but not in PowerShell version 2?

  • $collection | where $_.property -eq 'test'
  • $collection.where({$_.property -eq 'test'})
  • $collection | where property -eq 'test'
  • $collection | where {$_.property -eq 'test'} 

EXPLANATION

PowerShell v2 and v3 Differences
Where-Object no longer requires braces (source)

PS v2.0:
Get-Service | Where { $_.Status -eq 'running' }

PS v3.0:
Get-Service | Where Status -eq 'running'

PS V2.0 Error Message:
    Where : Cannot bind parameter ‘FilterScript’. Cannot convert the “[PropertyName]” value of the type “[Type]” to type “System.Management.Automation.ScriptBlock”.
 

Share:

What is the hardware portion of a database server responsible for?

What is the hardware portion of a database server responsible for?

  • Data presentation logic
  • Actionable and production-ready data
  • Data processing logic
  • Database storage 

EXPLANATION

The term database server may refer to both hardware and software used to run a database, according to the context. As software, a database server is the back-end portion of a database application, following the traditional client-server model. This back-end portion is sometimes called the instance.
It may also refer to the physical computer used to host the database. When mentioned in this context, the database server is typically a dedicated higher-end computer that hosts the database.
Note that the database server is independent of the database architecture. Relational databases, flat files, non-relational databases: all these architectures can be accommodated on database servers.
Share:

Monday, November 4, 2019

Which of the following is true about objects and/or classes in a database?

Which of the following is true about objects and/or classes in a database?

  • A class encapsulates only data
  • A class is an instance of an object
  • An object encapsulates only data
  • An object is an instance of a class 
Which of the following is true about objects and/or classes in a database?

EXPLANATION

An object is an instance of a class, and may be called a class instance or class object; instantiation is then also known as construction. Not all classes can be instantiated – abstract classes cannot be instantiated, while classes that can be instantiated are called concrete classes.

 

Share:

What command would you use to remove a row from a table in SQL?

What command would you use to remove a row from a table in SQL?

  • UPDATE FROM CUSTOMER
  • DROP FROM CUSTOMER
  • DELETE FROM CUSTOMER
  • REMOVE FROM CUSTOMER 
What command would you use to remove a row from a table in SQL?

EXPLANATION

SQL Delete Statement

The DELETE Statement is used to delete rows from a table.

Syntax of a SQL DELETE Statement

DELETE FROM table_name [WHERE condition];
  • table_name -- the table name which has to be updated.
NOTE: The WHERE clause in the sql delete command is optional and it identifies the rows in the column that gets deleted. If you do not include the WHERE clause all the rows in the table is deleted, so be careful while writing a DELETE query without WHERE clause.

SQL DELETE Example

To delete an employee with id 100 from the employee table, the sql delete query would be like,
DELETE FROM employee WHERE id = 100;
To delete all the rows from the employee table, the query would be like,
DELETE FROM employee;

SQL TRUNCATE Statement

The SQL TRUNCATE command is used to delete all the rows from the table and free the space containing the table.

Syntax to TRUNCATE a table:

TRUNCATE TABLE table_name;

SQL TRUNCATE Statement Example

To delete all the rows from employee table, the query would be like,
TRUNCATE TABLE employee;
Difference between DELETE and TRUNCATE Statements:
DELETE Statement: This command deletes only the rows from the table based on the condition given in the where clause or deletes all the rows from the table if no condition is specified. But it does not free the space containing the table.
TRUNCATE statement: This command is used to delete all the rows from the table and free the space containing the table.

SQL DROP Statement:

The SQL DROP command is used to remove an object from the database. If you drop a table, all the rows in the table is deleted and the table structure is removed from the database. Once a table is dropped we cannot get it back, so be careful while using DROP command. When a table is dropped all the references to the table will not be valid.
Syntax to drop a sql table structure:
DROP TABLE table_name;

SQL DROP Statement Example

To drop the table employee, the query would be like
DROP TABLE employee;
Difference between DROP and TRUNCATE Statement:
If a table is dropped, all the relationships with other tables will no longer be valid, the integrity constraints will be dropped, grant or access privileges on the table will also be dropped, if you want use the table again it has to be recreated with the integrity constraints, access privileges and the relationships with other tables should be established again. But, if a table is truncated, the table structure remains the same, therefore any of the above problems will not exist.

Share:

In programming, which type of loop will execute until a certain condition is met or not execute at all if the condition is initially false?

In programming, which type of loop will execute until a certain condition is met or not execute at all if the condition is initially false?

  • While
  • Do-While
  • For
  • If Else Statement 
In programming, which type of loop will execute until a certain condition is met or not execute at all if the condition is initially false?

EXPLANATION

The do/while statement creates a loop that executes a block of code once, before checking if the condition is true, then it will repeat the loop as long as the condition is true. The do/while statement is used when you want to run a loop at least one time, no matter what.
After the body of the 'for' loop executes, the flow of control jumps back up to the increment statement. ... If it is true, the loop executes and the process repeats itself (body of loop, then increment step, and then again condition). After the condition becomes false, the 'for' loop terminates.

 

Share:

Popular Posts