Добавить столбец в таблицу в phpmyadmin

Добавить столбец в таблицу в phpmyadmin

     .. (07-02-2009)

, , , . , , SQL.

«», , , . SQL, , CREATE TABLE. , ALTER TABLE, . .. SQL .

, SQL . , MySQL ALTER TABLE ( ).

, ? . ,

  SELECT * FROM Employees  ORDER BY last_name, first_name;  

Employees , (, ), , , Employees.

, Employees, :

  CREATE TABLE Employees(  emp_num INT NOT NULL PRIMARY KEY,  first_name CHAR(30) NOT NULL,  last_name CHAR(30) NOT NULL  );  

middle_name () first_name last_name.

MySQL :

  ALTER TABLE Employees ADD COLUMN middle_name CHAR(10) NULL AFTER first_name;  

SQL Server , :

» ;
» Employees ;
» Employees;
» Employees.

T-SQL, .

  --       CREATE TABLE Emp_temp(  emp_num INT NOT NULL PRIMARY KEY,  first_name CHAR(30) NOT NULL,  middle_name CHAR(30) NULL,  last_name CHAR(30) NOT NULL  );  GO  --         INSERT INTO Emp_temp(emp_num, first_name, last_name)  SELECT * FROM Employees;  GO  --     DROP TABLE Employees;  GO  --    EXEC sp_rename 'Emp_temp', 'Employees';  GO  

, middle_name NULL-. (, , Employees Emp_temp), . NULL.

SELECT INTO, » » :

  SELECT emp_num, first_name, CAST(NULL AS CHAR(30)), last_name  INTO Emp_temp  FROM Employees;  

CAST . -.

, , :

  ALTER TABLE Employees DROP COLUMN middle_name;  

, SELECT INTO . PRIMARY KEY ( ) , , :

  ALTER TABLE Emp_temp  ADD CONSTRAINT emp_PK PRIMARY KEY(emp_num);  

. , , . . *:

» ;
» ;
» ;
» , , , .

* . SQL. — .: — » «; .: , 2006

Dzone.com

| |


bsd.su




Источник: www.sql-ex.ru


Добавить комментарий