In: Computer Science
(PHP and MySQL)
How do you determine what size (in terms of subtype or length) a column should be?
What are some of the other properties that can be assigned to columns?
What is a primary key?
if you`re using the command-line myaql client to connect to MySQL,What username and password combination is required?
Solution:
For MySql:
36
If you want to find out the size of column=COLUMN_NAME from table=TABLE_NAME, you can always run a query like this:
SELECT sum(char_length(COLUMN_NAME))
FROM TABLE_NAME;
Size returned is in bytes. If you want it in kb, you could just divide it by 1024, like so:
SELECT sum(char_length(COLUMN_NAME))/1024
FROM TABLE_NAME;
To define SQL Server table column properties:
The SQL Server Table Column Editor opens.
Select the column in the Navigation Grid that you want to define and work with the following options:
Note: Click New on the toolbar to create a new column. Use the Enter filter text box to filter a very large list of columns to quickly locate the one that you want to define.
Primary Key:
The PRIMARY KEY constraint uniquely identifies each record in a table.
Primary keys must contain UNIQUE values, and cannot contain NULL values.
A table can have only ONE primary key; and in the table, this primary key can consist of single or multiple columns (fields).
UserName and Password:
An account may also have authentication credentials such as a password. The credentials are handled by the account authentication plugin. MySQL supports multiple authentication plugins. Some of them use built-in authentication methods, whereas others enable authentication using external authentication methods
There are several distinctions between the way user names and passwords are used by MySQL and your operating system:
User names, as used by MySQL for authentication purposes, have
nothing to do with user names (login names) as used by Windows or
Unix. On Unix, most MySQL clients by default try to log in using
the current Unix user name as the MySQL user name, but that is for
convenience only. The default can be overridden easily, because
client programs permit any user name to be specified with a
-u
or --user
option. This means that
anyone can attempt to connect to the server using any user name, so
you cannot make a database secure in any way unless all MySQL
accounts have passwords. Anyone who specifies a user name for an
account that has no password can connect successfully to the
server.
MySQL user names are up to 32 characters long. Operating system user names may have a different maximum length.
user
table. These passwords are distinct from
passwords for logging in to your operating system. There is no
necessary connection between the “external” password you use to log
in to a Windows or Unix machine and the password you use to access
the MySQL server on that machine.user
table. In this case,
it is possible that an external password is also used to
authenticate to the MySQL server.To connect to a MySQL server with a command-line client, specify user name and password options as necessary for the account that you want to use:
shell> mysql --user=finley --password db_name