I don't know what scalar means exactly, but I'm trying to see if I'm thinking about it correctly. Does scalar relate to arbitrariness where the type of data could be any type, or a system is not able to know what the data is in advance.
The term "scalar" comes from linear algebra, where it is used to differentiate a single number from a vector or matrix. The meaning in computing is similar. It distinguishes a single value like an integer or float from a data structure like an array. This distinction is very prominent in Perl, where the
$ sigil (which resembles an 's') is used to denote a scalar variable and an
@ sigil (which resembles an 'a') denotes an array. It doesn't have anything to do with the type of the element itself. It could be a number, character, string, or object. What matters to be called a scalar is that there is one of them.
A Scalar is simply a variable that holds an individual value. For purposes of this discussion, let's assume that a scalar is a single number, rather than a collection of numbers.
For example the result of a SQL query that returns a number instead of a tuple, as does the ExecuteScalar() method in the SQLCommand class, which returns the value of the first column of the first row in the result set returned by the query. It's typically used to retrieve an aggregate value such as a COUNT or AVERAGE, the ID of a new record, or the number of records processed by a query.
A supplemental mnemonic, to Karl Bielefeldt's great answer:
A simple way of thinking about it, is "can this be on a scale?"
An integer can be on a scale.
A fixed-size integer can be on a scale, e.g. from -2147483648 to 2147483647.
A real number can be on a scale.
A character, boolean, or fixed-precision decimal can all be on a scale. Even a string can be on a scale (we use such in sorting).
A database row cannot be on a scale. A complex number cannot be on a scale. An object representing an email message cannot be on a scale. An array, vector or matrix cannot be on a scale.
As is the case with many terms in computing; the origin of the word relates to more physical properties. The term Scalar is relatively old in computing. Its definition is less strict these days. When you store data in computer memory this data can either fit in one address (1 byte*) or not. When it did, it was called scalar, when it didn't it was called a composite. Mainly because CPUs could only handle one address/piece of data (= 1 byte) at a time. As stated by @Karl Bielefeldt; the term was indeed taken from algebra.
We call a string a string because it is a string of chars. A char is/was a scalar, while a string is/was a composite. Storing 1 piece of data (a datum) in multiple addresses blurred the line somewhat. Think of it like this: When a CPU could process a datum in one instruction, it was scalar.
These days a scalar is any singular value, and what a singular value is may be defined differently amongst different languages. integers, floats, chars, strings, booleans and enums are -for the most part- considered scalars these days. Arrays, lists, trees, objects, etc. are not.
(* I say 1 byte to keep things clear, but technically I am talking about the days when 6 bits were more commonly used on punch cards for example and later on magnetic strips)
Disclaimer: I am unable to find any references of this on the internet, I got the information at school and from old books, amongst which (I think): Mathematical Tables and other Aids to Computation from 1944. That being said, my memory is not what it used to be, so if anyone can amend/confirm or deny my answer, it would be nice.
A scalar is a simple single numeric value (as in 1, 2/3, 3.14, etc.), usually integer, fixed point, or float (single or double), as opposed to an array, structure, object, complex vector (real plus imaginary or magnitude plus angle components), higher dimensional vector or matrix (etc.) data type that contains more than one single numeric value.
However, note that a large very complex data type of the sort that can also be flattened and represented in 8-bit bytes of computer memory can also be represented as one single very long/large binary scalar number. Turing used this technique to represent entire computer programs as just one scalar number.
The word scalar derives from the Latin word scalaris, an adjectival form of scala (Latin for "ladder"). The English word "scale" also comes from scala. Source
A Scalar is a variable that holds an individual value.
Scalar Variable: Say that you are trying to represent the names of various students as a set of variables. Each of the individual variables is a scalar variable as follow
NAME01="Zara" NAME02="Qadir" NAME03="Mahnaz" NAME04="Ayan" NAME05="Daisy"
Scalar Functions: SQL scalar functions return a single value, based on the input value.
UCASE() - Converts a field to upper case LCASE() - Converts a field to lower case