Working with MySQL SQL 38 We have to (Java web hosting)

Working with MySQL SQL 38 We have to pick one of these data types for each of the pieces of data. Clearly, the username and password will be some number of characters. The question is whether we should use the CHAR or VARCHAR data type to represent the characters. The CHAR data type should be used if the character string will be a specific length and never change. In the case of a username and password, this is not the case. The user will be allowed to pick his or her username and password. This means we should use the VARCHAR data type for our character strings. Next, we need to determine the total number of characters that will be allowed in each of the strings. A value of 64 is more than likely enough. Finally, our attention turns to the account ID. Should the account ID be saved as an integer whole number or as a character string? If there is ever a chance the account ID will include alpha characters, then the ID should be a character string. With an integer, there are a few different types that can be used based on the potential size of the ID. For our example, let s use an INT data type for the field. Another characteristic that we want to place on the account ID is a primary key. A primary key basically states that the value in this column will be unique and thus can be used to uniquely identify any specific row in the table. Once we have identified all of the fields and assigned each a type, we can create the table. To create a nontransactional table, use this command: mysql> create table acc ( acc_id int primary key, username varchar(64), password varchar(64), ts timestamp); Query OK, 0 rows affected (0.00 sec) To create a table that will handle transactions, use this command: mysql> create table acc ( acc_id int primary key, username varchar(64), password varchar(64), ts timestamp) type=bdb; Query OK, 0 rows affected (0.01 sec) We can see all of the tables in our database with the following command: mysql> show tables; +——————–+ | Tables_in_accounts | +——————–+ | acc | +——————–+ 1 row in set (0.00 sec)
Note: If you are looking for reliable and quality webspace company to host and run your servlet application check professional servlet hosting services

Comments are closed.