Trending February 2024 # Explained With Examples + Video # Suggested March 2024 # Top 5 Popular

You are reading the article Explained With Examples + Video updated in February 2024 on the website Eastwest.edu.vn. We hope that the information we have shared is helpful to you. If you find the content interesting and meaningful, please share it with your friends and continue to follow and support us for the latest updates. Suggested March 2024 Explained With Examples + Video

Watch Video – Excel FILTER Function Examples

Office 365 brings with some awesome functions – such as XLOOKUP, SORT, and FILTER.

When it comes to filtering data in Excel, in the pre-Office 365 world, we were mostly dependent on Excel in-built filter or at max the Advanced filter or complex SUMPRODUCT formulas. In case you had to filter a part of a dataset, it was usually a complex workaround (something I have covered here).

But with the new FILTER function, it’s now really easy to quickly filter part of the dataset based on a condition.

And in this tutorial, I will show you how awesome is the new FILTER function and some useful things you can do with this.

But before I get into the examples, let’s quickly learn about the syntax of the FILTER function.

Below is the syntax of the FILTER function:

=FILTER(array,include,[if_empty])

array – this is the range of cells where you have the data and you want to filter some data from it

include – this is the condition that tells the function what records to filter

[if_empty] – this is an optional argument where you can specify what to return in case no results are found by the FILTER function. By default (when not specified), it returns the #CALC! error

Now let’s have a look at some amazing Filter function examples and stuff it can do which used to be quite complex in its absence.

Suppose you have a dataset as shown below and you want to filter all the records for the US only.

Below is the FILTER formula that will do this:

=FILTER($A$2:$C$11,$B$2:$B$11="US")

The above formula uses the dataset as the array and the condition is $B$2:$B$11=”US”

This condition would make the FILTER function check every cell in column B (one that has the region) and only those records that match this criterion would be filtered.

Also, in this example, I have the original data and the filtered data on the same sheet, but you can also have these in separate sheets or even workbooks.

Filter Function returns a result that is a dynamic array (which means that instead of returning one value, it returns an array that spills to other cells).

For this to work, you need to have an area where the result would come to be empty. In any of the cells in this area (E2:G5 in this example) already has something in it, the function will give you the #SPILL error.

Also, since this is a dynamic array, you can not change a part of the result. You can either delete the entire range that has the result or cell E2 (where the formula was entered). Both of these would delete the entire resulting array. But you can not change any individual cell (or delete it).

In the above formula, I have hard-coded the region value, but you can also have it in a cell and then reference that cell that has the region value.

For example, in the below example, I have the region value in cell I2 and this is then referenced in the formula:

=FILTER($A$2:$C$11,$B$2:$B$11=I1)

This makes the formula even more useful and now you can simply change the region value in cell I2 and the filter would automatically change.

You can also have a drop-down in cell I2 where you can simply make the selection and it would instantly update the filtered data.

You can also use comparative operators within the filter function and extract all the records that are more or less than a specific value.

For example, suppose you have the dataset as shown below and you want to filter all the records where the sales value is more than 10000.

The below formula can do this:

The formula checks each record for the value in Column C. If the value is more than 10000, it is filtered, else it’s ignored.

In case you want to get all the records less than 10000, you can use the below formula:

=FILTER($A$2:$C$11,($C$2:$C$11<10000))

You can also get more creative with the FILTER formula. For example, if you want to filter the top three record based on the sales value, you can use the below formula:

The above formula uses the LARGE function to get the third largest value in the dataset. This value is then used in the FILTER function criteria to get all the records where the sales value is more than or equal to the third-largest value.

Suppose you have the below dataset and you want to filter all the records for the US where sale value is more than 10000.

This is an AND condition where you need to check for two things – the region needs to the US and the sales need to be more than 10000. If only one condition is met, the results should not be filtered.

Below is the FILTER formula that will filter records with the US as the region and sales of more than 10000:

Since I am using two conditions and I need both to be true, I have used the multiplication operator to combine these two criteria. This returns an array of 0’s and 1’s, where a 1 is returned only when both the conditions are met.

In case there are no records that meet the criteria, the function would return the #CALC! error.

And in case you want to return something meaning (instead of the error), you can use a formula as shown below:

Here, I have used “Not Found” as the third argument, which is used when no records are found that match the criteria.

You can also modify the ‘include’ argument in the FILTER function to check for an OR criteria (where any one of the given conditions can be true).

For example, suppose you have the dataset as shown below and you want to filter the records where the country is either the US or Canada.

Below is the formula that will do this:

=FILTER($A$2:$C$11,($B$2:$B$11="US")+($B$2:$B$11="Canada"))

Note that in the above formula, I have simply added the two conditions by using the addition operator. Since each of these conditions returns an array of TRUEs and FALSEs, I can add to get a combined array where it’s TRUE if any one of the conditions is met.

Another example could be when you want to filter all the records where either the country is the US or the sale value is more than 10000.

The below formula will do this:

Note: When using AND criteria in a FILTER function, use the multiplication operator (*) and when using the OR criteria, use the addition operator (+).

You can use formulas within the FILTER function to filter and extract records where the value is above or below the average.

For example, suppose you have the dataset as shown below and you want to filter all the records where the sale value is above average.

You can do that using the following formula:

Similarly, for below average, you can use the below formula:

=FILTER($A$2:$C$11,C2:C11<AVERAGE(C2:C11))

In case you need to quickly filter and extract all the records from even number rows or odd number rows, you can do that with the FILTER function.

To do this, you need to check the row number within the FILTER function, and only filter row numbers that meet the row number criteria.

Suppose you have the dataset as shown below and I only want to extract even-numbered records from this dataset.

Below is the formula that will do this:

=FILTER($A$2:$C$11,MOD(ROW(A2:A11)-1,2)=0)

The above formula uses the MOD function to check the row number of each record (which is given by the ROW function).

The formula MOD(ROW(A2:A11)-1,2)=0 returns TRUE when the row number is even and FALSE when it’s odd. Note that I have subtracted 1 from the ROW(A2:A11) part as the first record is in the second row, and this adjusts the row number to consider the second row as the first record.

Similarly, you can filter all the odd-numbered records using the below formula:

=FILTER($A$2:$C$11,MOD(ROW(A2:A11)-1,2)=1)

Using FILTER function with other functions allows us to get a lot more done.

For example, if you filter a dataset using the FILTER function, you can use the SORT function with it to get the result that is already sorted.

Suppose you have a dataset as shown below and you want to filter all the records where the sales value is more than 10000. You can use the SORT function with the function to make sure the resulting data is sorted based on the sales value.

The below formula will do this:

The above function uses the FILTER function to get the data where the sale value in column C is more than 10000. This array returned by the FILTER function is then used within the SORT function to sort this data based on the sales value.

The second argument in the SORT function is 3, which is to sort based on the third column. And the fourth argument is -1 which is to sort this data in descending order.

So these are 7 examples to use the FILTER function in Excel.

Hope you found this tutorial useful!

You may also like the following Excel tutorials:

You're reading Explained With Examples + Video

What Are Live Service Games; Explained With Examples

You may have heard the term Live Service Games in recent times, but do you know what these games are and how they work? Not a lot of people do, but if you’re a gamer then we believe it is important to know these things. At the moment, several big video game companies are betting a lot on Live Service Games, and that’s because if successful, these titles can earn companies a lot of money because such games have a constant cash flow rather than pay once and never again.

Live Service Games explained with examples

Games as a Service (GaaS)

Live Service Games have been around for a number of years, but their popularity really took off with the rise of PUBG and Fortnite. Live Service Games, or Games as a Service (GaaS), are some of the most popular games today.

What are Live Service Games?

So, what is a Live Service Game, then? Well, it’s the type of video game that is designed to keep people playing on a regular basis for higher engagement. The idea is that instead of creating one game and then moving to the next to earn more money, it would make more sense to create a single title that spans a few years with new updates.

In order to keep players engaged, developers over the lifespan of the game must add new content on the regular. The more content, the more players will play and spend money, and that, if successful, can earn publishers millions of dollars in a short period of time.

For your information, Live Service Games are also known as Games as a Service or GaaS for short. For the longest time, many gamers were against these types of video games, but as the years roll out, we have witnessed folks warming up to such content.

Now, to some, Live Service Games are a new phenomenon, but in truth, they’ve been around for quite some time. For example, a lot of popular Facebook games in the past were Live Service Games, and the same can be said for World of Warcraft and other Massive Multiplayer Online games (MMO).

What makes a game a Live Service Game?

In order to make a game a Live Service Game, it should have the following features or options:

Such games are played online. So, a good internet connection is required to play a Live Service Game

A single game can be played for years with time-to-time updates

New content or updates are provided regularly (in weeks, every month, etc.)

New achievements are unlocked that keep gamers engaged and the game interesting to play

You get new characters, weapons, maps, etc.

How do Live Service Games work?

When a developer creates a Live Service Game, the plan is to release content on a regular basis that gamers are willing to pay for, hopefully. Such types of content can include weapons, skins, maps, emotes, and more. In some instances, a developer might launch a new game mode for a limited time.

Game developers may even come up with a Season Pass scheme where players pay a one-time fee to gain unlimited access to all the newest goodies in a single season.

Read: How to optimize Windows PC for Online Gaming

How do Live Service Games differ from others?

In the most important aspect, these types of games are no different when compared to others. The part that sets a Live Service Game apart from others is the online component. For example, a single-player game, if successful, will gain new content several times after launch for a limited time.

However, a GaaS game, if successful, will get extra content for players spanning multiple years. PUBG and Fortnite are some of the primary examples of this as these games are two of the most popular GaaS titles.

Additionally, most Live Service Games are of a free-to-play nature. The developer or publisher makes a profit by including microtransactions among other things. This is why Microsoft launched Halo Infinite as a free-to-play experience because it plans to push GaaS-related services.

The good and the bad characteristics of Live Service Games

Earlier release: Developers can release a game early and tweak it according to player feedback. Bear in mind though if an unfinished game is released in a bad state, then this usually means failure as gamers will probably never return for seconds.

Constant updates: The biggest downside for us where Live Service Games are concerned, is how updates are handled. Expect to download and install new updates up to 4 times or more per month. If you do not have unlimited bandwidth, then we suspect this could be taxing, so please keep all of this in mind.

Are Live Service Games here to stay?

Due to their huge popularity, we see several major publishers looking to this route in a bid to retain players and increase revenue. We believe before long the market might become saturated with GaaS titles, with only a few findings huge successes. So yes, Live Service Games are here to stay, but most won’t reach their full potential.

Read: Free multiplayer games for PC to play with friends from home

Are there any good Live Service Games?

There are plenty of good Live Service Games or GaaS available to play. Below you can see a few Microsoft titles right now:

Halo Infinite

World of Warcraft

Call of Duty: Warzone

Overwatch

Minecraft

Sea of Thieves.

How To Use Sticky Keys In Mac? (Explained With Examples) – Webnots

Mac has hundreds of keyboard shortcuts and many users rely on it instead of using the menu items. However, simultaneously pressing multiple keys in the shortcuts can be a problem for people with accessibility issues. For example, it will be quite difficult to use the shortcut keys “Option Shift Command V” in Pages app for “Paste and Match Style” menu. Thing is, it is even difficult for a normal person to hold three modifier keys and then press another key on the keyboard. It is impossible to use such shortcuts when you have movement problems with fingers. There comes the help of Sticky Keys which allows you to press the modifier keys one by one instead of pressing and holding them together.

Sticky Keys in Mac

If you are aware of using Sticky Keys in Windows PC, it works similarly on Mac. However, you have additional options to show the pressed keys on the monitor to make things much easier. Before using Sticky Keys in Mac, make sure you understand the symbols of modifier keys in Mac keyboard.

SymbolModifier Key⌥ or ⎇Option or Alt ⌘Command ⌃ControlfnFunction (or Globe) ⇧Shift⇪Caps Lock

Enable Sticky Keys in Mac

Follow the below steps to enable sticky in macOS Ventura or later versions. The macOS interface will be different if you are using old setup.

Scroll down on the left sidebar and select “Accessibility” option.

You will see list of items in the right pane and select “Keyboard” option under “Motor” section.

Keyboard Accessibility Settings in Mac

Turn the switch against “Sticky Keys” option to enable it.

Enable Sticky Keys in macOS Ventura or Later

Mac will show flash notification with command key mentioning “Sticky Keys On”.

Enable Sticky Keys in macOS Monterey

Any time later you can disable Sticky Keys by following the same steps and you will see a confirmation showing “Sticky Keys Off”. Remember, you can continue to hold all shortcut keys together to trigger the desired action even when you have enabled Sticky Keys option.

Customize Sticky Keys Settings in Mac

Sticky Keys Customizing Options in Mac

Press Shift Key 5 Times to Enable or Disable Sticky Keys

Beep when a modifier key is set – enable this to hear a beep sound whenever you press one of the modifier keys.

Display pressed keys on screen – turn this on to visually see the pressed key’s symbol on your display.

Locking Modifier Keys

Locking feature is one more important thing to understand when using Sticky Keys in Mac.

When you press a modifier key single time, it will simply show on the display. You can press escape or any other key to quit the Sticky Keys.

However, press any modifier keys two times to lock or hold in active state. You can press the same modifier key again to release and disable it.

Mac will play different sounds for single press and double pressing the modifier keys.

Single and Double Press Modifier Key

I wonder why Apple does not show these options clearly in the settings section.

Examples of Using Sticky Keys in Mac

Let me show some examples so that it is easy to understand especially the locking feature.

Example 1 – Command Control Space

Press Command, then Control and then Space keys one by one. You can see Command and Control keys on the monitor. However, when you press Space, all keys will disappear and the shortcut will open Character Viewer.

Example 2 – Command A, Command C, Toggle App and Command V

Let us say, you want to select all content from a Pages document, copy it to clipboard and then paste the copied content in another Word document. Here, you have sequence of actions with same Command key and you do not need to press it each time. Press Command key one time and you will hear a sound and see the display shows the key in a dimmed state. Now, one more time press Command key to hear different sound and the display will show it in bold state indicating the keys is locked.

First, press A key to select all content from Pages.

Next, press C key to copy selected content.

Use Tab to open App Switcher and press Space to select Word document.

Finally, press V keys to paste the copied content in Word.

Now, press Command key to release it and end the sequence.

Example 3 – Undo 10 Times with Command Z

This is another example for effectively using locking feature in Sticky Keys. When you want to undo 10 times in Pages or Word document, simply double press Command key to lock it. And then press Z keys 10 times to undo your changes. Finally, press Command key when you are done to release it.

Conclusion

Sticky Keys in Mac are very useful when frequently using shortcuts for daily work. However, it can easily annoy you if you do not know how to use it properly. I hope the above examples help you to understand better and I recommend using shift 5 times to enable or disable Sticky Keys feature.

Examples Of Sql Port With Explanation

Introduction of SQL Port

In networking, a port is a docking endpoint through which communication is established between the server and client and information flows from a program in the user’s computer to servers on the internet. In SQL also, we have multiple types of database engines such as SQL SERVER, POSTGRESQL, MYSQL etc. which communicate through ports. When a port number is used in combination with an IP address, it determines the direction of flow of information. These ports are part of the Transport Layer and are usually of two types TCP(Transmission Control Protocol) and User Datagram Protocol(UDP). Each port in the SQL database engine has a unique service to perform. For example, TCP 1433 is the default port number in SQL Server, and it is used for managing SQL instances over the network. While PostgreSQL uses TCP 5432 to perform the same task.

Start Your Free Data Science Course

Hadoop, Data Science, Statistics & others

In this article, we will attempt to illustrate how you can check the port number on which your SQL database engine is running, how it can be changed, and a few other things. For this article, we have written examples for PostgreSQL and SQL Server. But once you get the hang of it in any database engine, it’s quite intuitive in others.

Examples of SQL Port

Following are the examples are given below:

Example #1

How to find the port number to which the PostgreSQL database server is listening and change it to a new port number?

We can find out the port number and other details of the port to which the server is listening using a SELECT statement on the pg_settings table as shown below.

SELECT name, setting, category , short_desc FROM pg_settings WHERE name = 'port';

In this example, we have just fetched the port number, category, and description from the table. You can use SELECT * instead and fetch all the details. Now, observe the port number ‘5432’ and the short_desc corresponding to it. TCP port 5432 is the default to which the server listens to. For the curious ones, you can find more details on networking in SQL database server from the postmaster file or use the query given below.

select * from pg_settings where context = 'postmaster';

You will set some output, as shown in the image above.

Changing Port Number to A Different Port Number.

Step 1: Open SQL shell and write the following commands in the shell.

locate postgresql.conf

port = 5433 listen_addresses='*'

The above mentioned command will change the port number to ‘5433’ corresponding to all the IP addresses. You can get specific here by mentioning a specific IP address instead of ‘*’.

Example #2

How to find the port number to which the MS SQL server is listening and how to change it?

In SQL server, we have SQL Server configuration manager where we have all the configuration details saved. If you want to see what port number your database server is listening to follow the following steps then.

Step 1: Open SQL Server configuration manager. (If you are not able to find it directly look for it in the search tab)

 Step 2: Once you have opened your SQL Server configuration manager, open SQL Server Network Configuration as shown in the image below.

Step 5: If you wish to change the TCP port number then provide a new port number in the blank space corresponding to IP address 127.0.0.1, this corresponds to your localhost. You may make a change in IPALL if you want to change it for all the addresses.

And you are done changing the port number.

Conclusion

In this post, we have covered how to find the port number to which the SQL database server is listening to and have also learned to change it to a specific port number. A SQL port is basically a TCP port that acts as the endpoint of communication between your local computer and database server on the network.

Recommended Articles

We hope that this EDUCBA information on “SQL Port” was beneficial to you. You can view EDUCBA’s recommended articles for more information.

Sql Server Data Types With Examples

What is Data Type?

A Data Type in SQL server is defined as the type of data that any column or variable can store. It is a type of data that an object holds like integer, character, string, etc. While creating any table or variable, in addition to specifying the name, you also set the Type of Data it will store.

How to use MS SQL datatype

You can make efficient use of memory by assigning an appropriate data type to variable or column which will allocate only the required amount of system memory for the respective column’s data.

MS SQL offers a broad category of basic data types in SQL as per user’s needs like Date, binary images, etc.

In this tutorial, you will learn MS SQL data types with examples:

Why use DataTypes?

Let’s, take a sample of simple Sign up page of website application.Three input fields are First Name, Last Name & Contact number.

Here we should note that in real time:

“First/Last Name” will always be alphabetic.

“Contact” will always be numeric.

Data Types Example in MS SQL

From the above picture it worth defining “First/Last Name” as a character and “Contact” as an integer.

It is evident that in any application, all fields have one or the other type of data. E.g., numeric, alphabetic, date, and many more.

Also, note that different datatype has different memory requirement. Therefore, it makes more sense to define the column or variable with the data type it will hold for efficient use of memory.

Data type available in MS SQL Server

Here is MS SQL server data types list:

MS SQL server support following categories of Data type:

Exact numeric

Approximate numeric

Date and time

Character strings

Unicode character strings

Binary strings

Other data types

MS SQL Datatypes

Exact Numeric Data Types in SQL

Exact numeric has nine types of sub data types in SQL server.

Exact Numeric Data Types

Data Type Description Lower limit Upper limit Memory

bigint It stores whole numbers in the range given −2^63 (−9,223,372, 036,854,775,808) 2^63−1 (−9,223,372, 036,854,775,807) 8 bytes

int It stores whole numbers in the range given −2^31 (−2,147, 483,648) 2^31−1 (−2,147, 483,647) 4 bytes

smallint It stores whole numbers in the range given −2^15 (−32,767) 2^15 (−32,768) 2 bytes

tinyint It stores whole numbers in the range given 0 255 1 byte

bit It can take 0, 1, or NULL values. 0 1 1 byte/8bit column

decimal Used for scale and fixed precision numbers −10^38+1 10^381−1 5 to 17 bytes

numeric Used for scale and fixed precision numbers −10^38+1 10^381−1 5 to 17 bytes

money Used monetary data −922,337, 203, 685,477.5808 +922,337, 203, 685,477.5807 8 bytes

smallmoney Used monetary data −214,478.3648 +214,478.3647 4 bytes

Exact Numeric data types in SQL server with Examples:

Query:

DECLARE @Datatype_Int INT = 2 PRINT @Datatype_Int Output:

2

Syntax:

Decimal (P,S)

Here,

P is precision

S is scale

Query:

DECLARE @Datatype_Decimal DECIMAL (3,2) = 2.31 PRINT @Datatype_Decimal Output:

2.31

Approximate Numeric Data Types in SQL

SQL Approximate Numeric category includes floating point and real values. These datatypes in SQL are mostly used in scientific calculations.

Approximate Numeric Data Type

Data Type Description Lower limit Upper limit Memory Precision

float(n) Used for a floating precision number −1.79E+308 1.79E+308 Depends on the value of n 7 Digit

real Used for a floating precision number −3.40E+38 3.40E+38 4 bytes 15 Digit

Syntax: FLOAT [(n)]

Here, n is the number of bits that are used to store the mantissa of the float number in scientific notation. By default, the value of n is 53.

When the user defines a data type like float, n should be a value between 1 and 53.

SQL Server treats n as one of two possible values. If 1<=n<=24, n is treated as 24. If 25<=n<=53, n is treated as 53.

Example Query:

DECLARE @Datatype_Float FLOAT(24) = 22.1234 PRINT @Datatype_Float Output:

22.1234

Date and Time Data Types in SQL

It stores data of type Date and time.

Date and Time Data Type

Data Type Description Storage size Accuracy Lower Range Upper Range

DateTime Used for specifying a date and time from January 1, 1753 to December 31, 9999. It has an accuracy of 3.33 milliseconds. 8 bytes Rounded to increments of .000, .003, .007 1753-01-01 9999-12-31

smalldatetime Used for specifying a date and time from January 1, 0001 to December 31, 9999. It has an accuracy of 100 nanoseconds 4 bytes, fixed 1 minute 1900-01-01 2079-06-06

date Used to store only date from January 1, 0001 to December 31, 9999 3 bytes, fixed 1 day 0001-01-01 9999-12-31

time Used for storing only time only values with an accuracy of 100 nanoseconds. 5 bytes 100 nanoseconds 00:00:00.0000000 23:59:59.9999999

datetimeoffset Similar to datatime but has a time zone offset 10 bytes 100 nanoseconds 0001-01-01 9999-12-31

datetime2 Used for specifying a date and time from January 1, 0001 to December 31, 9999 6 bytes 100 nanoseconds 0001-01-01 9999-12-31

Example Query :

DECLARE @Datatype_Date DATE = '2030-01-01' PRINT @Datatype_Date Output:

‘2030-01-01’

Character Strings Data Types in SQL

This category is related to a character type. It allows the user to define the data type of character which can be of fixed and variable length. It has four kinds of data types. Below are the character string SQL server data types with examples.

Character Strings Data Types

Data Type Description Lower limit Upper limit Memory

char It is a character string with a fixed width. It stores a maximum of 8,000 characters. 0 chars 8000 chars n bytes

varchar This is a character string with variable width 0 chars 8000 chars n bytes + 2 bytes

varchar (max) This is a character string with a variable width. It stores a maximum of 1,073,741,824 characters. 0 chars 2^31 chars n bytes + 2 bytes

text This is a character string with a variable width. It stores a maximum 2GB of text data. 0 chars 2,147,483,647 chars n bytes + 4 bytes

Example Query :

DECLARE @Datatype_Char VARCHAR(30) = 'This is Character Datatype' PRINT @Datatype_Char Output:

This is Character Datatype

Unicode Character Strings Data Types in SQL

This category store the full range of Unicode character which uses the UTF-16 character encoding.

Unicode Character String Data Types

Data Type Description Lower limit Upper limit Memory

nchar It is a Unicode string of fixed width 0 chars 4000 chars 2 times n bytes

nvarchar It is a unicode string of variable width 0 chars 4000 chars 2 times n bytes + 2 bytes

ntext It is a unicode string of variable width 0 chars 1,073,741,823 char 2 times the string length

Example Query:

DECLARE @Datatype_nChar VARCHAR(30) = 'This is nCharacter Datatype' PRINT @Datatype_nChar Output:

This is nCharacter Datatype

Binary String Data Types in SQL

This category contains a binary string of fixed and variable length.

Binary String Data Types

Data Type Description Lower limit Upper limit Memory

binary It is a fixed width binary string. It stores a maximum of 8,000 bytes. 0 bytes 8000 bytes n bytes

varbinary This is a binary string of variable width. It stores a maximum of 8,000 bytes 0 bytes 8000 bytes The actual length of data entered + 2 bytes

image This is a binary string of variable width. It stores a maximum of 2GB. 0 bytes 2,147,483,647 bytes

Example Query:

DECLARE @Datatype_Binary BINARY(2) = 12; PRINT @Datatype_Binary Output:

0x000C

Other Datatypes in SQL

These are other different SQL server datatypes with the description below-

Data Type Description

Cursor It returns the name of the cursor variable.

Row version It version stamps table rows.

Hierarchyid This datatype represents a position in the hierarchy

Uniqueidentifier Conversion from a character expression.

Sql_variant It stores values of SQL server supported Datatypes.

XML It stores XML data in a column.

Spatial Geometry type It represents data in a flat coordinate system.

Spatial Geography type It represents data in the round-earth coordinate system.

table It stores a result set for later processing.

Interesting Facts!

CHAR data type is faster than SQL VARCHAR data type while retrieving data.

Summary:

Every column in tables defines with its datatype during table creation.

There are six main categories and one other miscellaneous category. Other miscellaneous have nine subcategories of SQL server data types and sizes available.

Types Of Java References With Examples

Introduction to Java References Types of Java References with Examples

There are four types of java references based on the Garbage Collector’s behaviour on the references.

Strong References: This is the default reference in java. Strong references can be created when an object is defined regularly.

Weak References: This reference is to be explicitly specified. The weak references can be created by using java.lang.ref.WeakReference class.

Soft References: Soft references can be created by using lang.ref.SoftReference class.

Phantom References: the phantom references can be created by using lang.ref.PhantomReference class.

1. Strong References

A strong reference is usually we use while we write the java code or we create an object. An object which has strong reference and active in the memory is not eligible for garbage collection, an object which has strongly referenced points to null can be garbage collected. For example, the below code snippet where variable ob is the object of the type ClassA.

ClassA ob = new ClassA();

An ‘ob’ object is having a strong reference to which is pointing to class ClassA; this object can not be garbage collected because an ob is an active object.

If reference ‘ob’ point to null as below –

ob = null;

Now the object is not referencing to class ClassA; an object is eligible for garbage collection now.

Example

Code:

package p1; class ClassA { } public class Demo { public static void main( String[] arg ) { ClassA ob = new ClassA(); System.out.println(ob); ob = null; System.out.println(ob); } }

Output:

2. Weak References ClassA ob = new ClassA();

Now the object is weak referencing to class ClassA, an object is now available for garbage collection, and it is garbage collected when JVM runs garbage collection thread.

Example

Code:

package p1; import java.lang.ref.WeakReference; class ClassA { } public class Demo { public static void main( String[] arg ) { ClassA ob = new ClassA();  System.out.println(ob); ob = null; System.out.println(ob); ob = weakob.get(); System.out.println(ob); } }

Output:

3. Soft References

The object of soft reference is not eligible for garbage collection until JVM runs out of memory or JVM badly needs memory. The weak references can be created by class lang.ref.SoftReference. For example, the soft reference can create Similarly to weak reference.

Example package p1; import java.lang.ref.SoftReference; class ClassA { } public class Demo { public static void main( String[] arg ) { ClassA ob = new ClassA();// default reference or Strong Reference System.out.println(ob); ob = null; System.out.println(ob); ob = softob.get(); System.out.println(ob); } }

Output:

4. Phantom References

An object of phantom reference is available for garbage collection, but before garbage collecting it, an object is put in a reference queue named as ‘reference queue’ by the JVM; after finalize() function call on the object. The weak references can be created by class chúng tôi PhantomReference.

Example

Code:

package p1; import java.lang.ref.ReferenceQueue; import java.lang.ref.PhantomReference; class ClassA { } public class Demo { public static void main( String[] arg ) { ClassA ob = new ClassA();  System.out.println(ob); ob = null; System.out.println(ob); ob = phantomob.get(); System.out.println(ob); } }

Output:

Recommended Articles

This is a guide to Java References. Here we also discuss the Introduction and types of java references along with different examples and their code implementation. You may also have a look at the following articles to learn more –

Update the detailed information about Explained With Examples + Video on the Eastwest.edu.vn website. We hope the article's content will meet your needs, and we will regularly update the information to provide you with the fastest and most accurate information. Have a great day!