Measure the test taker's understanding about the operations in a table in El.

Source: Internet
Author: User

Measure the test taker's understanding about the operations in a table in El.

Goal: Learn about table creation and modification and related operations.

Preface:

Oracle: The table is created in the user solution, rather than directly belongs to the database!

Sqlserver: The table directly belongs to the database!

  1. 1. Create a table:
  2. Keywords:Create
  3. Create TableTable Name (
  4. Column name 1, data type, other attributes,
  5. Column name 2, data type, other attributes,
  6. ...
  7. Other attributes of the last data type
  8. );
  9. Note: in oracle, when creating constraints, like SQL Server, they are also directly written.Primary Key,Check(Xxx), and so on, but the only difference is
  10. Foreign key constraints have some changes:
  11. Eg: typeIdIntCostraint (typeId) refereces TypeInfo (typeId );
  12. Instead:
  13. Eg: typeIdInt Foreign Key(TypeId) refereces TypeInfo (typeId );-- (Some of them are written in this way, but I have never written it !)
  14. 2. Table Modification
  15. A) add a column:
  16. Alter TableTable NameAddField Name Data Type attribute;
  17. B) Modify columns:
  18. Alter TableTable NameModifyColumn Name Data Type attribute;
  19. C) delete a column:
  20. Alter TableTable NameDrop ColumnColumn name;
  21. D) modify the table name:
  22. Alter TableRenameToNew table name;
  23. 3. Create a new table through an existing table (and enter existing data into the new table)
  24. Create TableNew table nameAs SelectColumn name 1, column name 2 ,....FromOld table name;
  25. 4. Table space operations:
  26. A) create a tablespace:
  27. CreateTablespace name datafile ='Tablespace path (the file name often ends with dbf )' SizeXXM;
  28. Note:SizeThe unit of the following number is not MB, but M, eg:Size50 m;
  29. B) create a temporary tablespace:
  30. Create TemporaryTablespace temporary tablespace name tempFile ='Path (same as the file name )' SizeXxM;
  31. C) Specify the tablespace for the user.
  32. Alter UserUser NameDefaultTablespace name;
  33. D) specify a tablespace for the table (which must be specified during creation ):
  34. Create TableXXX (
  35. XXX XX XXX
  36. ) Tablespace name;
  37. E) delete a tablespace:
  38. 1) only perform logical deletion, that is, delete the structure, but the physical file still exists:
  39. DropTablespace name incuding contents;
  40. 2) Delete All:
  41. Drop TableName: including contentsAndDatafile;
  42. F) modify the tablespace size:
  43. Alter DatabaseDatafile ='Path (and file name) of the newly added data file )'Resize XXM;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.