When char and nchar fields are filled with empty data, the database will automatically use all spaces instead, making the not null constraint meaningless. Therefore, if a field cannot be empty, it must be judged in advance in the program.
2. Because char and nchar have fixed lengths, it is said that the reading and writing speed is faster than varchar and nvarchar.
There are about 25 data types:
Binary [(n)],Varbinary [(n)],Char[(n)],Varchar[(n)],Nchar[(n)],Nvarchar[(n)],Datetime,Smalldatetime,Decimal [(p[,s])],Numeric[(p[,s])],Float[(n)],Real,Int,Smallint,Tinyint,Money,Smallmoney,Bit,CursorSysname,Timestamp,Uniqueidentifier,Text, Image,Ntext.
This may be three related nouns, the first is the array name. Array name refers to the name used to identify an array. In programming, in order to distinguish different arrays, we need to give them a name. For example, we can name arrays a, b, c1, etc. to use and distinguish them in the program.
The elements of the array refer to each data item stored in the array. To make it easier to use and distinguish different elements, we need to name them. In an array, we name each element using the array name plus a subscript. Subscripts start at 0, so the first element of the array a[] is a[0], the second is a[1], and so on. Subscripting allows us to access and manipulate exactly every element in an array.
Data type is a classification of data, used to reflect different types of things in the real world. Different programming languages may classify data types differently.
That’s it, friend. I don’t know if saying this can make you understand. Haha.
Array is a concept in programming language.
Databases, especially the current mainstream "relational databases", are specially used to store table structures.
So the standard SQL language is mainly aimed at data query and modification.
The functions of tables in the database are powerful enough. You can define multiple columns of different types, and you can even directly define whether it allows duplicates, etc.
In this case, it makes no sense to emphasize the concept of arrays. Because the purpose of a database is not programming, but data management.
As mentioned on the 2nd floor. Oracle defines arrays because it comes with plsql, which is a process-oriented programming language based on standard sql language. This language can write some procedures, functions, packages, etc.
We can observe that plsql is a process-oriented language in use. It is still very different from the use of ordinary sql statements. So it needs to be something customizable. For example, cursors, parameters, variables, return values, etc.
---------------------------------
So you understand, the SQL language used by ordinary databases does not clearly and directly define the concept of "array" because of different uses. The parts used for programming such as plsql have similar definitions.
-------------------------------------------------- ---------------
Additional explanation, the Oracle table structure is allowed to violate the first normal form. But personally I think this has no promotional significance.
import java.sql.*;
import java.util.Vector;
public class Test {
public static void main(String[] args) {
String strQuery = "SELECT * FROM rkd";
int[] id = getID(strQuery);
//Output test id array
for(int e : id){
System.out.println(e);
}
}
/**
* Get the number array based on the query string
* @param strQuery query string
* @return number array
*/
public static int[] getID(String strQuery) {
int[] id = null;
try {
//Query the member id in the database
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
Connection conn = DriverManager.getConnection("jdbc:sqlserver://localhost:1433;DatabaseName=Exam01","sa","123456");
Statement stat = conn.createStatement();
ResultSet rs = stat.executeQuery(strQuery);
//Save all ids into the temporary variable vect
Vectorvect = new Vector(); while(rs.next()){ vect.add(rs.getInt(1)); } //Dump all ids into the array id = new int[vect.size ()]; for(int i=0; i id[i] = Integer.parseInt(vect.get(i).toString()); } } catch (Exception e) { e.printStackTrace(); } return id ; } }
The above is the detailed content of Can an Oracle database field be set to an array type?. For more information, please follow other related articles on the PHP Chinese website!